Next: Secure

BMC/UUP-SITE - Locale

Support for localization (L10N) and internationalization (I18N) can be enabled using uup-site.sh and inside config/defaults.site. Translation is handled using the gettext extension.

Setup

Run uup-site.sh to create locale directory and install makefile:

uup-site.sh --locale
(i) Edit settings in makefile, then run 'make new-locale' and 'make' in current directory.

Initialize

The POT-file will be created by first make:

make
xgettext \
    --language=PHP \
    --package-name=sitename \
    --package-version=1.0 \
    --msgid-bugs-address=contact@example.com \
    --copyright-holder="Copyright notice for this application or site" \
    --add-comments='//{tr}' \
    --from-code=UTF-8 \
    --no-wrap \
    --output=locale/messages.pot \
public/auth/logoff/index.php public/auth/logon/index.php public/standard.menu public/dispatch.php public/view.php public/welcome.php 
    ...

Create a new locale:

make new-locale
Locale: sv_SE.UTF-8
The new message catalog should contain your email address, so that users can
give you feedback about the translations, and so that maintainers can contact
you in case of unexpected technical problems.

Is the following your email address?
  andlov@asusx555u.unix.qnet
Please confirm by pressing Return, or enter your email address.

Retrieving http://translationproject.org/team/index.html... done.
A translation team for your language (sv) does not exist yet.
If you want to create a new translation team for sv, please visit
  http://www.iro.umontreal.ca/contrib/po/HTML/teams.html
  http://www.iro.umontreal.ca/contrib/po/HTML/leaders.html
  http://www.iro.umontreal.ca/contrib/po/HTML/index.html

Created locale/sv_SE.UTF-8/LC_MESSAGES/messages.po.

bash$> find locale
locale/
locale/sv_SE.UTF-8
locale/sv_SE.UTF-8/LC_MESSAGES
locale/sv_SE.UTF-8/LC_MESSAGES/messages.po
locale/messages.pot

bash$> tree locale
locale/
├── messages.pot
└── sv_SE.UTF-8
    └── LC_MESSAGES
        └── messages.po

2 directories, 2 files

Update

Run make in current directory to update, merge and compile your message files (*.po):

make
msgfmt --statistics --check --output-file=locale/sv_SE.UTF-8/LC_MESSAGES/messages.mo locale/sv_SE.UTF-8/LC_MESSAGES/messages.po
0 translated messages, 71 untranslated messages.

bash$> tree locale
locale
├── messages.pot
└── sv_SE.UTF-8
    └── LC_MESSAGES
        ├── messages.mo
        └── messages.po

2 directories, 3 files

Edit

Use emacs or jed with po-mode or use the poedit application for editing the po-files.