Sorry but I can’t read all messages. I’m french and sometimes english is a little hard for me. And I do not have enough time to translate all. So, I prefer continue this post to talk about my experience.
* All the "main page" meta-data (page-title, alias, etc.)
* Keyword metadata.
* All the TVs associated with a page
* Number/Date formats
* Manager/System Configuration language setting
* Chunks/Snippets/Plugins/Modules
I add "Templates"
Is it possible to make it "easly" in the modx core but it is long.
I propose all that follows, based on my experience. This way had be choiced after many tests with several possibilities of implementation (MySQL performances and simplicity of implementation). There are all solutions but I think is good compromise.
Use a session variable to store the language used by the user ($_SESSION[’lang’])
This variable permit to retrieve easily paths, tables, etc... (Thanks to see below).
Use 1 database (is the better solution) and 1 table by language (only for content, metatag, keywords... : all tables that contains localized string). Also, it is necessary to separate localized tables and setting tables. Tables wich contain localized contents must have reference at the language. Exemple : site_content_en, site_content_en.
This avoid to make heavy one table. Requests in database are faster on little table than bigger.
An other possiblity is to add fields to store reference to the language but request is longer and more complicated (need to make condition for select rows instead (1st solution) select directly in the good table)
Use language files to display messages and strings of the interface.
Note: Settings which are displayed in table like key / value can’t be localized easly. I think there are oonoly for administrator, sor they can be unlocalized. A solution is to use language file to display parameters but it’s need a link between parameter and string. I think is too heavy.
Use 2 files for each languages for Modx (not ressources) : it is not necessary to load all language strings if users are only on the frontend or on the backend (actually, I don’t know if english.inc.php are used in front and back).
Use language files for all ressources.
Templates must be use tag to replace after by localized string.
Each language files can be found easly with the session variable. I think the better solution is use the language identifier in the name of the file.
A modx core function could be added to load automatically language file with a simple call in the ressource. This core function can be automatically load 2 languages : in first the modx default language and in second the current language (thanks to session variable
). If the required string is not in the second file, the first will be automatically used instead (language files must used PHP array for this).
Use setlocale() to display date, monetary... correctly. It can be automatized with the session variable.
TV would make called to string in the database. All string can be used because TV are created by users. A file to store string is to hard to mantain and difficult to consult. To simplify the administration of this custom string, I think a table by language is required.
All ressources must be reconsider : final user can want to display only document in one language, without indicate that a version exists in an other language. Is an fats idea.. I don’t think more about this...
Default charset must be UTF-8 because many language use accented characters or other "special" characters.
Some functions must be added in modx core. Now, I think only to a function to format date (using strftime and utf8_encode). I’m sure there are other function which required this treatment. A list off this functions should be great...
To manage and display easly the different language, a table must be created with the name of the language (localized so that everybody can retrieve easly their language), string for set_locale (fr_FR, en_EN...) (with this, this is not obligatory to add set_locale in language file). Also, it can permit to automize addition of language.
To display content with multi language, a great functionnality is to indicate if traduction exists. For this goal, the key of localized table must be same in all calized table. To simplify it in the backend, a good way is to create a document in one language, and create after a 2nd document with a function "Translate" which get the table id and display the first document (read only mode). Also, all translated documents will have the same id. An other table must be created to count translation for optimize request, and still one to store every document id with every language id. With the MySQL index, as this tables contains only id, requests are very fast.
A structure of directory must be created to store language files. I think that :
root
|_ manager
| |_ lang
| |_ frontend
| | |_ modx.en.inc.php
| | |_ modx.fr.inc.php
| | |_ modx.it.inc.php
| |
| |_ backend
| |_ modx.en.inc.php
| |_ modx.fr.inc.php
| |_ modx.it.inc.php
|_ assets
| |_ snippets
| | |_ newslisting
| | | |_ php
| | | |_ lang
| | | |_ language.en.inc.php
| | | |_ language.fr.inc.php
| | | |_ language.it.inc.php
| | |
| | |_ newsfeed
| | |_ php
| | |_ lang
| | |_ language.en.inc.php
| | |_ language.fr.inc.php
| | |_ language.it.inc.php
| |
| |_ plugins
| |_ xxxx
| | |_ php
| | |_ lang
| | |_ language.en.inc.php
| | |_ language.fr.inc.php
| | |_ language.it.inc.php
Note : the project that I developped has 2 languages (french and englis) for the interface (frontend and backend) and documents can be write in each language needed (and configured in the database) (to my knowledge, if no modification were made, Greek, Czech, Dutsh, Italian, Portuguese and Spanish).
A great possiblity of modx should be parsed all ressources (I know that is not easy) and display in the manager all ressources which are not translate in user language : it permits to avoid to display english (if user language does not exist).
Only core ressources/modx messages can be hardcoded than "Can’t load default language" or "Can’t found a required file".
I think I have said all that I know. But I don’t sure.
I repeat : it is my view based on my experience.
All comments are welcome.
Thanks everybody for having read all my "english".