Closed polinwei closed 7 years ago
Hi! On what page?
In http://mysite.com , I see those words: NAV_HOME, NAV_ABOUT, NAV_CONTACT, NAV_MY_MENU
In http://mystart.com/admin , those words are TITLE_HOME ,TITLE_USERS,TITLE_USERS
I change to 'language' => 'en' , then workable. strange.
I found your layout will cut off the full word. I look the source code is <html lang="ru">
or <html lang="en">
<html lang="<?= mb_substr(Yii::$app->language, 0, strrpos(Yii::$app->language, '-')); ?>">
<html lang="<?= Yii::$app->language; ?>">
May I ask you which the rule for the i18 message? I found those message in modules, api, backend, common...
In the main template, the translation is global, for its frontend, for backend its correspondingly
\Yii::t('app', 'NAV_HOME');
Global translations are in the messages folder of the corresponding application
frontend https://github.com/Dominus77/yii2-advanced-start/tree/master/frontend/messages
backend https://github.com/Dominus77/yii2-advanced-start/tree/master/backend/messages
In modules, the structure is the same, but it is called differently if the translation is not global
Example:
\modules\main\Module::t('module', 'Home');
The translations are in
modules \ main \ messages \ en \ module.php
and
modules \ main \ messages \ ru \ module.php
Accordingly, you need to configure this in Module.php and Bootstrap.php https://github.com/Dominus77/yii2-advanced-start/tree/master/modules/main and connect in the config application Bootstrap.php https://github.com/Dominus77/yii2-advanced-start/blob/288682261f87af0a72a6abb2693d55d0076c8fe5/frontend/config/main.php#L16
Understood. thanks.
Sorry !! Ask other questions: After I changed the layout to
<html lang="<?= Yii::$app->language ?>">
why not work?
And in the config parameter language? https://github.com/Dominus77/yii2-advanced-start/blob/288682261f87af0a72a6abb2693d55d0076c8fe5/frontend/config/main.php#L11 This parameter is set there
I setup 'language' => 'en-US' in common\config\main.php
layout:
<html lang="<?= Yii::$app->language ?>">
but Chinese is work !! Ha , It is I need.
'language' => 'zh-TW'
Then this parameter in the backend and frontend should be removed or commented out
https://github.com/Dominus77/yii2-advanced-start/blob/288682261f87af0a72a6abb2693d55d0076c8fe5/frontend/config/main.php#L11
frontend and backend
//'language'=>'ru-RU',
common
'language' => 'zh-TW'
Yes , I did it . but not workable for 'en-US'
Not displayed in code?
<html lang="en-US">
HTML code is show <html lang="en-US">
but message is the key 'NAV_HOME....'
in the application's messages folder, there is an en-US folder and the app.php translation file in it? https://github.com/Dominus77/yii2-advanced-start/tree/288682261f87af0a72a6abb2693d55d0076c8fe5/frontend/messages/en-US
At me all works, I switch language in common, the language changes to Russian or English
Probably my work is English because by default I'm writing in English, now I'll check with the contants))
I am only not work for 'en-US' , others is fine. FYI
Thanks , I am learning much from you.
Checked, specify 'en' instead of 'en-US'
I'm still that teacher))) I can tell if I know myself.
By the way, recently made a plug-in for highlighting syntax, I advise you to look instead of SyntaxHighlighter https://github.com/Dominus77/yii2-highlight-plugin
Got it . Thanks a lot.
Hi Sir: When I set up 'language' => 'en-US' in common\config\main.php , backend & frontend not found the current message file. Which file I need to setup?
<?php return [ 'name' => 'Yii2-advanced-start', 'timeZone' => 'Asia/Taipei', 'language' => 'en-US', 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',