Z
Z
zaartix2015-06-11 13:49:16
Yii
zaartix, 2015-06-11 13:49:16

Accepted practices for project internationalization (IDE, Phpstorm), how do you write templates?

Can you please tell me how it is customary to translate websites into different languages? As far as I understand, there are 2 approaches to building templates (example on twig):

  • {{ t('String') }}
  • {{ t('#ID_STRING') }}

In the first case, everything is fine, the template is quite convenient to read, but problems arise when a typo is found in a line, the translation fails with any changes in this line.
In the second case, the readability of the templates is greatly degraded.
As far as I understand, there should be solutions at the IDE level for the second option, when the string itself will be displayed instead of the identifier. Unfortunately, I could not find a solution to this issue, apparently due to the fact that I do not really understand how to formulate a query in a search engine.
Share please the experience who how translates interfaces.
Yii Framework 1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2015-06-11
@ollisso

If you use adequate id in id_string, then everything works very well and easily.
Adequate id, for example:
error_no_user_found
error_wrong_password
success_user_registered
And so it is clear what is written there, but how it will be in the final text is usually not so important.

A
Alexander N++, 2015-06-11
@sanchezzzhak

Translations in the IDE(phpStorm) with autocomplete are a big problem, because the IDE does not see the array keys of the dictionary
On one project I named it like this
File message.model.php
return [
'NAME_ATTR' => 'Name',
'NAME_PLACEHOLDER' => 'Enter your name '
];
+ A bunch of dictionary files were from View models
and the other interface separately, I didn’t throw everything into one pile.
Where there was no translation, there was a stupid text output in the NAME_PLACEHOLDER style, which was immediately evident.
Translations are still that butt-pain.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question