duna
(Info)
May 11, 2011, 10:24am
1
Hello.
I have some questions about i18n:
How can I get the list of months from /framework/i18n/data/<locale>.php
I have some messages in protected/messages/de/test.php. These messages are only taken when I set Yii::app()->setLanguage(‘de’); not if I set it to ‘de_de’ or ‘de_at’. What am I doing wrong here?
Where do I have to put the central code to detect and set the users language
duna
gusnips
(Gustavo)
May 11, 2011, 10:39am
2
Question 1:
http://www.yiiframew …nthNames-detail
question 2:
Dont know because I use db messages (check out this extension I just posted)
question 3:
onBeginRequest event is the best place
duna
(Info)
May 11, 2011, 10:45am
3
Thank you. I will try it.
Where would I put the function and register the it to the event?
gusnips
(Gustavo)
May 11, 2011, 11:03am
4
Its worth it , and not saying that Its because I made it, but because after I made it its very easy to add a new languages to my applications.
create a class called lets say "Bootstrap" with a method "init" (you can call the method and class as you wish)
in you main config file
return array(
//...
'onBeginRequest'=>array('Bootstrap','init'),
//...
'components'=>array(
//...
)
);
PS: the class must be imported, put it in the components folder
duna
(Info)
May 11, 2011, 11:07am
5
Its worth it , and not saying that Its because I made it, but because after I made it its very easy to add a new languages to my applications.
create a class called lets say "Bootstrap" with a method "init" (you can call the method and class as you wish)
in you main config file
return array(
//...
'onBeginRequest'=>array('Bootstrap','init'),
//...
'components'=>array(
//...
)
);
PS: the class must be imported, put it in the components folder
Fine, thank you.
When I install your module the class "Controller" could not be found by the loader. Do you habe any idea?
gusnips
(Gustavo)
May 11, 2011, 11:15am
6
I dont think its related to the module, but with your app, because the controllers in the module extend from CController
anyway, create em empty class "Controller" that extends CController in your components folder
Let me know what you think of the module
Cheers
duna
(Info)
May 11, 2011, 11:17am
7
Same problem here. The file de.php contains the following array for the wide month names:
array (
1 => 'Januar',
2 => 'Februar',
3 => 'März',
4 => 'April',
5 => 'Mai',
6 => 'Juni',
7 => 'Juli',
8 => 'August',
9 => 'September',
10 => 'Oktober',
11 => 'November',
12 => 'Dezember',
),
da_at.php contains just the different month name of the january in austria:
array (
1 => 'Jänner',
),
Now Yii::app()->getLocale()->monthNames contains only an array with this one element 1 => ‘Jänner’ when language is set to de_at.
duna
(Info)
May 11, 2011, 11:20am
8
I dont think its related to the module, but with your app, because the controllers in the module extend CController
anyway, create em empty class "Controller" that extends CController in your components folder
The class Controller exists and everything works fine if I remove the module. I think I have made an error in the configuration.
gusnips
(Gustavo)
May 11, 2011, 11:25am
9
I see.
What you did was to replace the old import index in the config doing like:
'import'=>array(
'application.modules.translate.TranslateModule'
),
what you need to do is to just add this line to your old import index:
'application.modules.translate.TranslateModule'
same with the index components, just add this in your old components index:
'messages'=>array(
'class'=>'CDbMessageSource',
'onMissingTranslation' => array('TranslateModule', 'missingTranslation'),
),
As for your other problem, this seens weird, I’ll do some tests and let you know …
gusnips
(Gustavo)
May 11, 2011, 11:30am
10
Couldn’t you use always “de” isntead ?
duna
(Info)
May 11, 2011, 11:36am
11
I see.
What you did was to replace the old import index in the config doing like:
'import'=>array(
'application.modules.translate.TranslateModule'
),
what you need to do is to just add this line to your old import index:
'application.modules.translate.TranslateModule'
same with the index components, just add this in your old components index:
'messages'=>array(
'class'=>'CDbMessageSource',
'onMissingTranslation' => array('TranslateModule', 'missingTranslation'),
),
No I dind’t. I have to look. I must have done something wrong there…
I think I have to. I found this old thread here:
http://www.yiiframework.com/forum/index.php?/topic/3136-l18n-language-fallback/
But if this fallback isn’t supported why are there onkly the specific changes stored in de_at.php?
duna
(Info)
May 11, 2011, 11:49am
12
I see.
What you did was to replace the old import index in the config doing like:
'import'=>array(
'application.modules.translate.TranslateModule'
),
what you need to do is to just add this line to your old import index:
'application.modules.translate.TranslateModule'
same with the index components, just add this in your old components index:
'messages'=>array(
'class'=>'CDbMessageSource',
'onMissingTranslation' => array('TranslateModule', 'missingTranslation'),
),
As for your other problem, this seens weird, I’ll do some tests and let you know …
Okay, it is installed. Had an error in my configuration. Will try it now…
duna
(Info)
May 11, 2011, 12:20pm
13
Okay. It works. Thank you. Has been one point of the specifications! Two suggestions:
gusnips
(Gustavo)
May 11, 2011, 12:40pm
14
Thanks!
I had already corrected when I was looking for the problem you were having. But thanks for pointing it out. Soon I’ll upload a new version.
-True. I just add that in the extension page.
Anyway, thanks for the suggestions, any more suggestions, requests or bugs please let me know in this thread