-
Notifications
You must be signed in to change notification settings - Fork 536
I18N
Annotator now has rudimentary support for localisation of its interface.
If you wish to use a provided translation, you need to add a link
tag pointing to the .po
file, as well as include gettext.js
before you load the Annotator. For example, for a French translation:
<link rel="gettext" type="application/x-po" href="locale/fr/annotator.po">
<script src="lib/vendor/gettext.js"></script>
This should be all you need to do to get the Annotator interface displayed in French.
If you wish to create a new localisation, you will need to have GNU gettext installed. Once you do, you can check out the Annotator sources and use the provided scripts to create a new .po
file, using locale/annotator.pot
as a template. For example, to start a new German translation, move to the locale/
directory, and run:
./l10n-new de
This will create locale/de/annotator.po
, which you can then edit by hand or using a tool such as Poedit.
If you wish to update an existing translation with new strings from the template, you should run (again using a German localisation as an example):
./l10n-update de
This will add any missing translation strings to locale/de/annotator.po
, which you can then update and save.
Any localisable string in the core of Annotator should be wrapped with a call to the gettext function, _t
, e.g.
console.log(_t("Hello, world!"))
Any localisable string in an Annotator plugin should be wrapped with a call to the gettext function, Annotator._t
, e.g.
console.log(Annotator._t("Hello from a plugin!"))
To update the localisation template (locale/annotator.pot
), you should run the i18n:update
Cake task:
cake i18n:update
You should leave it up to individual translators to update their individual .po
files with the locale/l10n-update
tool.