I encountered this problem several times when creating websites. As an example, I will explain the use of PHP and Laravel, but this problem is a common multi-level platform. This has already been discussed in several questions ( post1 , post2 , post3 , post4 and some others), but the messages really did not get a good answer.
Question: What is the best way to structure translated content within language files?
I am currently using Laravel (I am not mentioning the version because Laravel 4 and Laravel 5 have similar localization functionality, at least fairly similar to the purple of this topic).
Localization structures content according to language files (en, es, de, fr ...), inside which there can be several .php files containing a return statement that returns a multi-level structure of the dictionary.
/lang /en messages.php /es messages.php
and the files contain something like this:
<?php return [ 'example1' => 'example message for value exaple-key', 'example2' => [ 'sub-example' => 'example message for example1.sub.example', ], ];
and the call to this is done by doing something like this:
//Laravel 5 trans('messages.example1'); //outputs 'example message for value exaple-key' trans('messages.example2.sub-example'); //outputs 'example message for example1.sub.example' //Laravel 4 Lang::get('messages.example1'); //outputs 'example message for value exaple-key' Lang::get('messages.example2.sub-example'); //outputs 'example message for example1.sub.example'
Several grouping methods come to mind:
website content
example: homepage.php, page1.php, page2.php...
by logical domain:
example: auth.php, validation.php, pagination.php...
by html:
example: buttons.php, popup_messages.php, form_data.php...
by live broadcast:
example: simple_words.php, phrases.php... and contain content like 'password-to-short' => 'your password is to long'
Some hybrids / combinations mentioned above
They all have some obvious advantages and disadvantages, and I will not try to use int, but the 5th option is most likely the best solution, but there is still the problem of where to draw the line to get minimal duplication of phrases and content.
The problem with user rights is the solution to the problem of the first uppercase characters in some cases and lowercase in other cases, as well as punctuation characters at the ends.
I have made a reaserch regarding this issue, but there are no definitive recommendations and / or good examples available to study.
All opinions are welcome.