S
S
Sergey2016-02-21 08:57:33
Yii
Sergey, 2016-02-21 08:57:33

How to arrange date translation?

I'm trying to arrange date translation through echo \Yii::t('app', 'Today is {0, date}', time()); From this article , I have two questions.
1 Is it necessary to organize the app.php document for the date or not?
2 How to organize app.php for dates well on the same date March and January?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Arutyunov, 2016-02-21
@Serggalas

Have you tried the formatter?
Translates the date into the correct language based on the active language. Works even on multilingual sites.

D
Dmitry Voronkov, 2016-02-21
@DmitryVoronkov

1.In the above configuration, app* is a template that defines which categories are processed by the source. In our case, we are processing everything that starts with app. The message files are located in @app/messages (the messages folder in your app). The fileMap array determines which file will be included for a particular category. If you don't want to configure fileMap, you can rely on the convention that the category name is the file name. For example, the app/error category refers to the app/error.php file under basePath.
When translating a message \Yii::t('app', 'This is a string to translate!') with the application language set to ru-RU, Yii will first look for the @app/messages/ru-RU/app.php file to get list of available translations. If there is an ru-RU file, Yii will also try to look for ru before deciding that the translation attempt failed.
2. How the localization file is organized, you can see here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question