Developing i18n support

From KnowledgeTree Document Management Made Simple

Jump to: navigation, search

i18n is Internationalisation, the process of providing support for multiple locales - specific languages and cultures. In the case of KnowledgeTree, translation is the primary focus.

KnowledgeTree provides the ability for developers to add support for multiple languages within their plugins.

There are two main locations where text can occur in KnowledgeTree - PHP source code files, and templates.

In the short term, PHP source code files use gettext directly. Here is an example of using gettext:

    print _("some text");
    $var = sprintf(_("%d apples picked by %s"), $count, $picker);

In templates, the \{i18n} block function can be used to mark up text that should be translated:

    <h2>{i18n}Some text{/i18n}</h2>
    <p>{i18n arg_count=$count arg_picker=$picker}#count# apples picked by #picker#{/i18n}</p>

By default, templates use the default gettext domain "knowledgeTree". The use of "i18n_domain" passed to the template or to the i18n block can be used to change this:

    <h2>{i18n i18n_domain="myplugin"}Some plugin related stuff{/i18n}</h2>

Plugins can register their own domain when they register their other actions, portlets, and triggers:

    $oPlugin->registeri18n("ktstandard.subscriptions.i18n", "subscriptions/i18n");
Personal tools