Creating new language module - unacms/UNA GitHub Wiki
By default UNA supports English and Russian languages. If you want to translate to to another language then the best way is to create new language module. The easiest way to do this is to clone Russian module.
-
Copy Russian module from
/modules/boonex/russian/to your own directory, for example/module/vendor/french/, where vendor is your or organization name. -
Edit
modules/vendor/french/install/config.phpfile and change all possible values, particularly:-
'name' => 'vend_fr'- for 2 letters code use ISO 639-1 standard and some abbreviation for your or your organization name 'title' => 'French''version' => '1.0.0''vendor' => 'Vendor'-
'compatible_with' => array('9.0.0')- specify particular version here 'home_dir' => 'vendor/french/''home_uri' => 'fr'-
'db_prefix' => 'bx_fr_'- database tables prefix, it's not used but needed anyway 'class_prefix' => 'VendFr''language_category' => 'Vendor French'- comments at the top of the page
-
-
Edit
modules/vendor/french/install/installer.phpfile by changing the comment at the top of the page and class name, useclass_prefixspecified in point 2:class VendFrInstaller extends BxDolStudioInstaller -
Edit
modules/vendor/french/install/langs/en.xmlfile, by changing only the following:- change all language key prefixes to your own, for example from
_bx_rsn_to_vend_fr_ - change translations from
RussiantoFrench
- change all language key prefixes to your own, for example from
-
Edit SQL files in
modules/vendor/french/install/sql/folder by changing all occurrences of the following:-
bx_rutovend_fr- thenamevalue from the point 2 -
boonex/russian/tovendor/french/- thehome_dirvalue from the point 2 -
RussiantoFrench- thetitlevalue from the point 2 -
'ru'to'fr'- thehome_urivalue from point 2 -
_bx_rsn_to_vend_fr_- like in point 4
-
-
Change images in
modules/vendor/french/template/images/icons/folder, use the following guide and PSD template to create new one, please use flag picture - instructions on how to create module icon -
It's recommended to translate from English, to do it go to
modules/vendor/french/data/langs/folder, then:
a) insystemfolder: remove 'ru.xml' file
b) insystemfolder: copymodules/boonex/english/data/langs/system/en.xmlfile from English
c) insystemfolder: then rename it fromen.xmltofr.xml
d) insystemfolder: editfr.xmlby changing the header:`<resources name="fr" flag="fr" title="French">` and translate the values: `<string name="_lang_key"><![CDATA[Translate only here]]></string>`e) repeat the same for each module folder, but copy original English translation from
install/langsfolder in the module. For example for Posts module copy and renamemodules/boonex/posts/install/langs/en.xmlfile tobx_posts/fr.xmlNOTE: Most of these steps can be automated with the special script which copies all english xml files to one place, type in UNA root folder -
phing package_all_langs(phing binary must be installed). This way you will have all language files inpackages/enfolder. Then copy files frompackages/enfolder tomodules/vendor/french/data/langs/folder. Then you will need to perform c), d), e) steps from above list.NOTE: to get translations for all modules refer to the UNA GitHub repository.
NOTE: it's possible to rename all files in
data/langsfolder using the following MAC OSX command:find . -name en.xml | while read f; do mv -v "$f" "$(echo "$f" | sed -e 's/en.xml/fr.xml/')"; doneNOTE: it's possible to search and replace strings in
data/langsfolder files using the following MAC OSX commands:
find . -name it.xml -exec sed -i '' 's/name="en"/name="fr"/g' {} \;
find . -name it.xml -exec sed -i '' 's/flag="gb"/flag="fr"/g' {} \;
find . -name it.xml -exec sed -i '' 's/title="English"/title="French"/g' {} \; -
When new version of UNA is released you need to update module and add/remove/change some language keys. The list of changed language keys can be found in English module update files, also you can also use it as a template to create own language module update. For example the here is the list of changes from 9.0.0 to 9.0.1 for English language.
How to write upgrade script for the module refer to the following doc:
https://github.com/unaio/una/wiki/Creating-app-auto-update-script -
To package the module, run the following from your UNA root folder (it requires build.xml file which is in the UNA repository):
/path/to/phing package_module -Dvendor=your_vendor_folder_name -Dmodule=your_module_folder_name
ZIP file for the module will appear in/packages/folder in your UNA root directory.