Revision #14 has been created by c@cba on Feb 19, 2012, 10:52:34 PM with the memo:
I want to factor in not only the plural form, but also the grammatical cases (especially the accusative, as in 'Manage Objects' for example) during the translation
« previous (#13)
Changes
Title
unchanged
How to obtain a grammatically correct translation of the model name in giix-generated view files
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
i18n, grammatical cases, translation, giix, How to
Content
changed
[...]
**b.** Add the following function definition into your model file `models\Object.php`:
```php
public static function label($n = 1, $case=self::NOMINATIVE) {
if($n == 1)
return Yii::t('app', 'n==1#Object|n==2#Object|n==3#Object|n==4#Object', $case);
else if($n > 1)
return Yii::t('app', '
n==1#Objects|n==2#Objects|n==3#Objects|n==4#Objects', $case);
}
```[...]
```php
'Manage {model_entries}'=>'{model_entries} Yönet',
'n==1#Object|n==2#Object|n==3#Object|n==4#Object'=>'
n==1#Obje|
n==2#Objenin|
n==3#Objeye|
n==4#Objeyi', '
n==1#Objects|n==2#Objects|n==3#Objects|n==4#Objects'=>'
n==1#Objeler|
n==2#Objelerin|
n==3#Objelere|
n==4#Objeleri',
```
**d.** Now let's use this in the view files, and take care of the order of the words:[...]
public static function label($n = 1, $case=self::NOMINATIVE) {
if($n == 1)
return Yii::t('app', 'n==1#<?=$modelClass;?>|n==2#<?=$modelClass;?>|n==3#<?=$modelClass;?>|n==4#<?=$modelClass;?>', $case);
else if($n > 1)
return Yii::t('app', 'n==1#<?=$modelClassP;?>|n==2#<?=$modelClassP;?>|n==3#<?=$modelClassP;?>|n==4#<?=$modelClass;?>', $case);
else if($n > 1)
return Yii::t('app', '<?=$modelClassP;?>', $case);
}
~~~
Then work through the view files under `\extensions\giix-core\giixCrud\templates\default\` and replace translations as described in step d.
That's it. If something is unclear/wrong/incomplete or you have other suggestions please let me know.[...]