[solved] Create translation folder for EN?

Hi Guys!

I know that we usually translate for example like that:

create app/messages/de/somefile.php

With following content:




"English Text Message" => "German Text Message" 



And call translation like:




Yii::t('somefile', 'English Text Message'); 



And that is all fine and good, but im just curious if it is possible to create a "en" folder and use some kind of "placeholder" for the translation of messages. Maybe I just have not seen it in the guide / docs.

For better understanding what I mean…

Imagine you have a long sentence to translate like for example:

“The quick brown fox jumps over the lazy dog. The dog doesn’t care because he is lazy.”

Now it would be nice to call translation like that:


 Yii::t('somefile', 'lazy dog sentence');



And of course in the translation files:

de/somefile.php

en/somefile.php

… we have the whole sentence.

Does YII support something like that out of the box?

Or do I have to override something?

Any suggestions?

Best Regards

You need to force translation https://github.com/samdark/yii2-cookbook/issues/48

As SamDark said, by default, translation will NOT happen if the source and target languages are the same, but you can set forceTranslation to true as per his link to make it happen.

I found the same issue as you but beware of forcing translation because it can add a large overhead to the performance of your system. If most people use it in English and your messages are in English, then the database or translation files don’t need to be queried most of the time.

Understood.

Thanks for your answers guys! :)

Regards