Thursday, May 2, 2024
HomeGolangGo-playground/validator: assist a number of languages for translations - Getting Assist

Go-playground/validator: assist a number of languages for translations – Getting Assist


Whats up all,

I’m following this instance to allow translations for validation errors.
The instance works however I don’t perceive tips on how to add assist for a number of translations.

My software is a HTTP REST backend and the language for use for translation is detected studying the Settle for-Language header of the HTTP request.

My fundamental downside is that additionally if I register a number of languages with

uni = ut.New(en, en, it.New(), fr.New())

the language used for translations is all the time en additionally if in my handler I do

trans, _ := uni.GetTranslator("it")

errs := err.(validator.ValidationErrors)
errs.Translate(trans)

I checked that calling

trans, discovered := uni.GetTranslator("it")

the worth of discovered is true.

Any ideas?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments