New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern 'Update {modelClass}' with Yii::t() #246
Conversation
``` $this->title = Yii::t('project', 'Update {modelClass}: ', [ 'modelClass' => 'Project', ]) . $model->name; ``` => ``` $this->title = Yii::t('project', 'Update {modelClass}: ', [ 'modelClass' => Yii::t('project', 'Project'), ]) . $model->name; ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a line for changelog.
something like this?
|
Yes, something like that. |
Would you please push it to the branch? |
Merge mainline master
Merge master
@@ -16,7 +16,9 @@ | |||
/* @var $this yii\web\View */ | |||
/* @var $model <?= ltrim($generator->modelClass, '\\') ?> */ | |||
|
|||
$this->title = <?= $generator->generateString('Update {modelClass}: ', ['modelClass' => Inflector::camel2words(StringHelper::basename($generator->modelClass))]) ?> . $model-><?= $generator->getNameAttribute() ?>; | |||
$this->title = <?= strtr($generator->generateString('Update {modelClass}: ', ['modelClass' => '{modelClass}']), [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it more, how about generating just Yii::t('app', 'Update Post')
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it more, how about generating just Yii::t('app', 'Update Post')?
contr: I think this pattern applied for many model in one translate part.
[
'Update {modelClass}' => 'Обновить {modelClass}',
'Model1' => 'Модель1',
'Model2' => 'Модель2',
]
and 'Model1', 'Model2' can be use in another place
pro: create
already have Yii::t('app', 'Create Post')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is necessary to bring both to one form
[
'Update {modelClass}' => 'Обновить {modelClass}',
'Create {modelClass}' => 'Создать {modelClass}',
'Model1' => 'Модель1',
'Model2' => 'Модель2',
]
or
'Update Model1' => 'Обновить Модель1',
'Create Model1' => 'Создать Модель1',
'Update Model2' => 'Обновить Модель2',
'Create Model2' => 'Создать Модель2',
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While Yii::t('app', 'Create Post')
means more translation work, translation itself could be much better because you have more context in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am for putting it together. In languages, where different forms are necessary dependent on the grammatical gender of a word this will produce problems, e.g.:
'Create a Post' => 'Einen Beitrag erstellen',
'Create an Annotation' => 'Eine Anmerkung erstellen',
Eine
vs. Einen
and even in english there is a
and an
if you want to add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And may be add
to translating pattern a number/name/other_key
$model-><?= $generator->getNameAttribute() ?>
of model?
Yii::t('app', 'Update Post {name}', ['name' => $model->id])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's fine to add it.
Merged. Thank you! |
The generator does not translate the model name.
=>