7)Describe the process of creating a binary gettext .mo file. How would this file be used within a web app?
The process of create .mo file
1. extract all the things we need to translate from a given file to generate .po file. We use command xgettext as,
xgettext -L PHP filename.php
2. Then, fill in msgstr to translate each msgid in .po file.
3. using .po file to generate a .mo file using command like:
msgfmt -o message.mo message.po
Then, put the .mo file in correct directory
using them in web
locale which indicates which language is used is often stored in a session variable.
using commands like:
putenv('LC_ALL=en_US');
setlocale(LC_ALL, 'en_US'); // say locale
bindtextdomain("myMoFile", "./locale"); // say locale dir
textdomain("myMoFile"); // say .mo file
in php using gettext(“some msgid”), it will get the indicated language.
(
Edited: 2016-05-16)
*Qiao Liu
* Enkhtur Badamsaikhan
7)Describe the process of creating a binary gettext .mo file. How would this file be used within a web app?
'''The process of create .mo file'''
1. extract all the things we need to translate from a given file to generate .po file. We use command xgettext as,
xgettext -L PHP filename.php
2. Then, fill in msgstr to translate each msgid in .po file.
3. using .po file to generate a .mo file using command like:
msgfmt -o message.mo message.po
Then, put the .mo file in correct directory
'''using them in web'''
locale which indicates which language is used is often stored in a session variable.
using commands like:
putenv('LC_ALL=en_US');
setlocale(LC_ALL, 'en_US'); // say locale
bindtextdomain("myMoFile", "./locale"); // say locale dir
textdomain("myMoFile"); // say .mo file
in php using gettext(“some msgid”), it will get the indicated language.