Locale
Swarm is fully localized; with an appropriate language pack installation, Swarm can support users in multiple languages.
A language pack consists of gettext
-style
default.po
and default.mo
files,
placed in a folder named for the locale they represent, within the
language
folder in the Swarm root directory. In
addition, language packs contain two javascript files to provide
translation strings for the in-browser UI,
and
locale
.js
, which both
appear in the locale
.jsgz
folder.
SWARM_ROOT
/public/build/language
The following example illustrates the directory layout of a language pack:
SWARM_ROOT
/ language/locale
/ default.mo default.po public/ build/ language/locale
.jslocale
.jsgz
You can configure certain localization behaviors with the
translator
configuration block in the
file.
Here is an example:
SWARM_ROOT
/data/config.php
<?php
// this block should be a peer of 'p4'
'translator' => array(
'detect_locale' => true,
'locale' => "",
'translation_file_patterns' => array(),
),
The detect_locale
key determines whether Swarm attempts
to detect the browser's locale. The default value is
true
. Set the value to false
to
disable browser locale detection.
The locale
key is a string specifying the default locale
for Swarm. Alternately, an array of 2 strings can be used to specify the
default locale, and a fallback locale. For example:
<?php
// this block should be a peer of 'p4'
'translator' => array(
'locale' => array("en_GB", "en_US"),
),
The translation_file_patterns
key allows you to customize
Zend's translation infrastructure, which you might do if you are developing
your own language pack. For details, see
Zend\I18n.