Difference between #13 and #14 of
How to obtain a grammatically correct translation of the model name in giix-generated view files

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.
[...]
4 0
1 follower
Viewed: 19 691 times
Version: 1.1
Category: How-tos
Written by: c@cba
Last updated by: c@cba
Created on: Feb 10, 2012
Last updated: 12 years ago
Update Article

Revisions

View all history