Loading...
 

Strings Format Convention

 Warning

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

 Warning

The part of this which is not about conventions should move to Creating or maintaining translations.

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 across Tiki, some rules need to be followed.
Some are arbitrary, some are for correct English. Feel free to propose other rules.

English conventions (capitalization)

  • 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.

Other

  • 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}

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

Keywords

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.

Accessibility (WAI & 508)
Accounting
Administration
Ajax
Articles & Submissions
Backlinks
Banner
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution
Cookie
Copyright
Credits
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping
Mobile
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment
PDF
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Scheduler
Score
Search engine optimization (SEO)
Search
Security
Semantic links
Share
Shopping Cart
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
Webmail and Groupmail
WebServices
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives
WYSIWTSN
WYSIWYCA
WYSIWYG
XMLRPC
XMPP




Useful Tools