Fullscreen
Loading...
 
[Show/Hide Right Column]

Close
noteNote
This page is to document "what Tiki should do". For feature documentation (what Tiki does), please see corresponding page on doc site

Strings Format Convention

Close
warningWarning
All information for end users to be able to translate should be in a workspace on tiki.org


About

This page is for developers and theme creators who edit strings to translate (mainly the *.tpl files). In order to minimize the language file, and to have the same look accross Tiki, some rules need to be followed.
Some are arbitrary, some are for correct English. Feel free to propose other rules.

Strings in the Tiki layout

Strings in general

  • in a title, each first letter of significant words is upper case
    • Ex: {tr}Messages and Strings Format{/tr}
  • the same applies to labels of actions or button links
    • Ex: {tr}Create a New Structure{/tr} {tr}Export{/tr} {tr}Cancel Edit{/tr}
  • in a menu, if it's a main Tiki feature or a named section each first letter of significant words is upper case, otherwise (when it's a request for an action) the string has an upper case first letter only
    • Ex: {tr}Image Gallery{/tr} {tr}System Admin{/tr}
      but
      {tr}Submit a new link{/tr} {tr}List surveys{/tr}

Tables of listings

  • in a column header, the label is upper case first letter only
    • Ex: {tr}Name{/tr} {tr}Last author{/tr}

Forms

  • a text near radio button switch has an upper case first letter only
    • Ex: {tr}Yes{/tr}
  • before a text input, the label has an upper case first letter only and is followed by ":"
    • Ex: {tr}Upload picture:{/tr} not {tr}Upload picture{/tr}:
      Note: placing the ":" string inside the translation allows languages to choose whether to omit, use ": ", " : ", " :-", or something else.

Localized strings

Dealing with variables

PHP variables should never be placed directly inside localized strings. Instead you should use placeholders. See examples below.

  • PHP: use tr("Changed from %0 to %1", $old, $new) instead of tr("Changed from $old to $new")
  • Smarty: use {tr _0=$old _1=$new}Changed from %0 to %1{/tr} instead of {tr}Changed from $old to $new{/tr}


The problem with variable is that strings for translation are extracted from the source code while to display them to the user they are interpreted by PHP. So, for example, the string below:

"$comments_cant comments"

Translators will see the above string as it appears in the source code ("$comments_cant comments") but in the application $comments_cant will be replaced by the variable value. Tiki will never find the translation for "10 comments" or any other value of $comments_cant.

Best practices

  • Avoid slang and abbreviations.
  • Use entire sentences since word order change from language to language.
  • Use placeholders instead of variables inside the string (explained above).


Based on suggestions from Gettext manual.

Common mistakes

Below is a list of examples of what you should NOT do (they were all extracted from Tiki and need to be fixed):

  • Wrong: tra('To send an email once the tracker item has been created. Format: from').'|'.tra('to').'|'.tra('template')
    Correction: tr('To send an email once the tracker item has been created. Format: from|to|template')
  • Wrong: {tr}There are no wiki pages similar to '{$page}'{/tr}
    Correction: {tr _0=$page}There are no wiki pages similar to '%0'{/tr}

Other considerations for developers


Learn how to run get_strings.php and do the following:

  • Spellcheck your strings. If you save the old language.php file, you only need to spellcheck the difference. Translators have to "retranslate" spelling corrections
  • If you improve an english string, please consider pages mass spelling correction and Pending text corrections in order to avoid extra work for translators
  • Look in (the English) language.php and see if there is a phrase that you could use. There are already too many variants, e.g.;
    • Create/Edit xxx
    • Create/edit xxx
    • Create or edit xxx
    • edit/create
    • create/edit
    • Edit or Add xxx
    • Add or Edit xxx
    • Add or edit xxx
    • click to edit
    • edit
    • edit this xxx
    • edit new xxx

Although some of the variants above might have a justification it seems like creativity is winning over conformance...

  • Stay with one possible variation if there are more in English when defining new strings to be translated, e.g.:
    • Use email everywhere instead of e-mail


We should plan to switch to using tokens and default strings - discussion over at I18n

Alias


Spaces [toggle]

Search Wishes (subject only) [toggle]

Keywords [toggle]

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.




TogetherButton [toggle]

Documentation: PluginTogether