| Class | Translation |
| In: |
app/models/translation.rb
|
| Parent: | ActiveRecord::Base |
Comas uses GetText for the system translation. GetText is a very powerful, scalable and widely used translation system - But it does not fare very well with dynamic content, as translations must be compiled. That‘s why, for all database-stored content, we introduced this ad-hoc, homegrown and lightweight translation system.
Translation was modelled to be similar in behaviour to GetText - You should populate your database with the strings in the default language. We advise you to stick to English as the default language, as to keep consistency with the rest of the Comas system, even if your installation‘s main language is different.
This system will basically cover two kinds of translation:
To ensure no name collisions on two different domains force you into choosing a single translation for both, catalog rows will be prefixed for translation with the catalog‘s name and a vertical bar
corresponding translation key will be ‘Room|Auditorium’. This qualifier will be automatically dropped when the translation is requested, even if no string has yet been specified (only ‘Auditorium’ will be shown).
To use a Translation-based string, use the for class method:
Translation.for('something to be translated')
Creates a new, empty Translation object for the specified string and language. The language can be specified as the second argument (defaults to the currently defined language)
Gets the translation for the specified string on the currently selected locale (or the locale specified as a second parameter).
If the translation has not yet been made for this language, an empty Translation will be stored in the database (ready for the system administrator to fill in), and the original string (minus any table qualifiers - see the class’ documentation) will be returned.
Find all the translatable strings and create them (leaving them as empty strings if they are not already defined) in the current language.