A
A
Alexander Stepanov2019-03-15 01:14:51
Yii
Alexander Stepanov, 2019-03-15 01:14:51

How to add multilanguage \ translation to the dropdown list of the form?

There is an API of Nova Poshta in which everything is wonderful, except for one thing - the regions are stored only in Ukrainian, and the store, only in Russian ...
I encountered internationalization in Yii2 and everything was easily solved with a wrapper in Yii::t () ...
Yes the idea that you need to split the array of areas in the model / controller by enumeration and wrap the names in the enumeration, and then collect the array again, but ...
Is there any other way to fasten the translation to dropDownList or is this the only one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-03-15
@Exebeche

I think you need to have two arrays with the same keys and that's it. If speech only about dropDown. How many areas are there. And you can have a method in the model that will return one or another array depending on the language. Or if you need it somewhere else, you can put it in a helper or even assemble the widget. Here it is already necessary to use it according to the project - and arrange it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question