Translate
From TomatoCMS Documentation
Contents |
Language files location
TomatoCMS supports multilingual site. There are language file for each modules and widgets belonging to module. Following image gives you an idea of where these languages file are:
How to make a language package
As you see in image above, there is not directory that consist of all languages file for modules/widgets. Fortunately, from 2.0.4 version, TomatoCMS allows you to upload a language package in zip format that contain all language files.
For example, I want to create a French package for TomatoCMS, just follow the steps:
Step 1: Define the language code
All language files, for both module and widget, have name in format of lang.LanguageCode_CountryCode.ini. It's probably that the language and country code are familiar to developers/translators.
For example:
- English: en_US, where en is language code and US is country code
- Vietnamese: vi_VN
- French: fr_FR
Step 2: Create a language directory
Create a directory on your local computer which will be used to contain our language files.
Step 3: Create language file for module
Name of module language file has format of NameOfModule.lang.LanguageCode_CountryCode.ini For example, if you want to create French package for ad module:
- Copy the English file for ad module located at app/modules/ad/languages/lang.en_US.ini and paste to your language folder (created in step 2)
- Rename it to ad.lang.fr_FR.ini
- Open it in your text editor and update the value of key, i.e, all strings are in the right side of equal (=) characters.
[about] about_news_description = "...Translate it to French..." dashboard_list_articles = "...Translate it to French..." dashboard_add_article = "...Translate it to French..." dashboard_list_hot_articles = "...Translate it to French..." permisson_article = "...Translate it to French..." permisson_article_activate = "...Translate it to French..." ...
Step 4: Create language files for widgets
It's similar to step 3. The name of widget language file has format of NameOfModule.widgets.NameOfWidget.lang.LanguageCode_CountryCode.ini For example, following is what you have to do for creating French package for breadcump widget in news module:
- Copy the English package version from app/modules/news/widgets/breadcump/lang.en_US.ini
- Paste it to your language folder (created in step 2)
- Rename it to news.widgets.breadcump.lang.fr_FR.ini
- Open file in your text editor and update all string which are in the right side of = characters.
After creating French package for all modules and widgets, your folder will look like:
Step 5: Create package
Just compress your folder in *.zip extension.
How to upload new language package
(This feature is only available from 2.0.4 version)
IMPORTANT NOTE: If you want to use uploading feature, your server must have zlib or zip extensions. To check whether one of two extensions was already installed on your server or not, check the output of http://site.com/tomatocms/phpinfo.php:
In back-end, go to Customize >> Language menu. Select your language package and click Upload button.
How to switch to new language
It's very simple to switch your site to new language. Just update the language setting in application configuration file (app/config/app.ini):
... [web] language = "fr_FR" ...
If you are going to switch to Arabic, Iranian, ... languages which has right-to-left (RTL) direction, don't forget to update the setting:
... [web] lang_direction = "rtl" ...




