This repository holds the Zolinga module.
Please refer to Zolinga PHP Framework for more information. Also refer to inbuilt Zolinga WIKI that comes with the your Zolinga framework installation for most up-to-date information.
Zolinga is focused on multilingual support. This means that the system is designed to support multiple languages and locales. This is achieved by using the gettext library.
First you need to install the Zolinga framework. See Zolinga PHP Framework. Then you can install the Zolinga CMS module by running this command in the root of your Zolinga installation:
$ ./bin/zolinga install --module=zolinga-intl
- Locale
- A set of parameters that defines the user's language, region, and any special variant preferences that the user wants to see in their user interface. A locale name is usually in the form
language_TERRITORY
, wherelanguage
is an ISO 639 language code, andTERRITORY
is an ISO 3166 country code. For example,en_US
is the locale for US English, andfr_FR
is the locale for French in France.
- A set of parameters that defines the user's language, region, and any special variant preferences that the user wants to see in their user interface. A locale name is usually in the form
- msgid
- A string identifier. This is a unique identifier for a string that needs to be translated. It is used to look up the translated string in the translation files. The
strid
is usually the English version of the string. For example, thestrid
for the string "Hello" is "Hello".
- A string identifier. This is a unique identifier for a string that needs to be translated. It is used to look up the translated string in the translation files. The
- msgstr
- The translated string. This is the translated version of the
msgid
. For example, themsgstr
for the string "Hello" in French is "Bonjour".
- The translated string. This is the translated version of the
- domain
- Each domain groups a set of related translations. In Zolinga, the domain is the name of the module that the translation is for. For example, the domain for the
zolinga-intl
module iszolinga-intl
.
- Each domain groups a set of related translations. In Zolinga, the domain is the name of the module that the translation is for. For example, the domain for the
- PO file
- A Portable Object file. This is a file that contains the translations for a domain. It is a text file that contains the
msgid
andmsgstr
pairs for a domain. The file has a.po
extension and is located in folderlocale
in the module's directory.
- A Portable Object file. This is a file that contains the translations for a domain. It is a text file that contains the
- MO file
- A Machine Object file. This is a binary file that contains the translations for a domain. It is a compiled version of the PO file. The file has a
.mo
extension and is located in folderlocale
in the module's directory.
- A Machine Object file. This is a binary file that contains the translations for a domain. It is a compiled version of the PO file. The file has a
$api->locale
- service to get and set the current locale and more.
- Dynamic PHP
- Dynamic JavaScript
- translation using the javascript version of the
gettext
library. You can use thegettext
andngettext
functions in your JavaScript code. Read more in Zolinga inbuilt WIKI. - Example:
console.log(gettext('Hello'));
- translation using the javascript version of the
- Static HTML files
- translation using the
gettext
library. You can add thegettext
attribute to any HTML tag to translate the text inside the tag or any of its attributes. System will automatically pre-generate static translated HTML files. Read more in Zolinga inbuilt WIKI. - Example:
<h1 gettext=". title" title="Welcome!">Hello!</h1>
- translation using the
The translation workflow consists of the following steps
- Marking the translatable strings
- You need to mark the translatable strings in your code. For details refer to the specific section for the type of translation you want to use.
- translating HTML (see Zolinga inbuilt WIKI) static files
- translating PHP (see Zolinga inbuilt WIKI) dynamic files
- translating JavaScript (see Zolinga inbuilt WIKI) dynamic files
- You need to mark the translatable strings in your code. For details refer to the specific section for the type of translation you want to use.
- Extracting the translatable strings
- You need to extract the translatable strings from your code. This will generate a
.po
files by scanning your code. The scanning and extraction is done by thebin/zolinga gettext:extract --module={MODULE}
command. The result are.po
files in thelocale
directory of the module.
- You need to extract the translatable strings from your code. This will generate a
- Translating the strings
- You need to translate untranslated strings in the
{MODULE}/locale/*.po
files. You can use any text editor or a specialized translation tool like Poedit.
- You need to translate untranslated strings in the
- Compiling the translations
- You need to compile the translations to generate the
.mo
files for PHP,.json
dictionaries for Javascript or.{lang}_{TERRITORY}.html
static translations for HTML. The compilation is done by thebin/zolinga gettext:compile --module={MODULE}
command.
- You need to compile the translations to generate the
The list of languages is configured in Zolinga's file {ROOT}/config/global.json
.
Example:
{
"intl": {
"locales": [
"en_US",
"cs-CZ"
]
}
}