Class Translation
In: app/models/translation.rb
Parent: ActiveRecord::Base

Translation - Handle translation for strings in the database

Why?

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.

What?

This system will basically cover two kinds of translation:

Table qualifiers

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

  • i.e. if you have an ‘Auditorium’ entry in your ‘Room’ catalog, the

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

Regular usage

To use a Translation-based string, use the for class method:

   Translation.for('something to be translated')

Methods

Classes and Modules

Class Translation::NotYetTranslated

Public Class methods

Find all the translatable strings registered for all the defined languages, and create blank (empty) translations for whichever languages they are not yet defined

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.

Public Instance methods

Is this translation pending? This means, is its translated string empty or nil?

[Validate]