FORMfields


FORMfields.FfLanguageHelper

Class FfLanguageHelper

FfLanguageHelper

public class FfLanguageHelper

FfLanguageHelper a class used to implement multilanguage support.

Since:
FORMfields v3.0

Field Summary
mixed

$language

The current language or the language associated with the user instance.

mixed

$translationFilename

The local path to the translation file.

mixed

$translations

A an array of arrays where the 1st row is the language headings where the index is the value of the 1st column or label.

mixed

$translationsLoaded

True if the translations file has been loaded.

Constructor Summary

FfLanguageHelper()

Creates a new FfLanguageHelper.

__construct()

Creates a new FfLanguageHelper.

Method Summary
string

getLanguage()

Returns the current language.

void

loadTranslationsIfNeeded()

Loads the translations file if needed: if the translations file hasn't been loaded.

void

setLanguage(string language)

Sets the current language.

void

setTranslationFilename(string translationFilename)

Sets the translation filename and sets the translationsLoaded value to false.

mixed

translate(mixed label)

Returns the translation(s) for the given label(s).

string

translateLabel(string label)

Returns the translation for the given label.

Field Detail

language

public mixed $language

The current language or the language associated with the user instance.

Since:
FORMfields v3.0

translationFilename

public mixed $translationFilename

The local path to the translation file.

Since:
FORMfields v3.0

translations

public mixed $translations

A an array of arrays where the 1st row is the language headings where the index is the value of the 1st column or label. For the following rows: the 1st element is the label and the following elements are the translations associated with the column headings.

Since:
FORMfields v3.0

translationsLoaded

public mixed $translationsLoaded = false

True if the translations file has been loaded.

Since:
FORMfields v3.0

Constructor Detail

FfLanguageHelper

public FfLanguageHelper()

Creates a new FfLanguageHelper.

Since:
FORMfields v3.0
Deprecated:
remove when PHP 5 becomes the requirement as this is not the PHP 5 syntax for a constructor

__construct

public __construct()

Creates a new FfLanguageHelper.

Since:
FORMfields v3.0

Method Detail

getLanguage

public string getLanguage()

Returns the current language.

Returns:
the current language
Since:
FORMfields v3.0

loadTranslationsIfNeeded

public void loadTranslationsIfNeeded()

Loads the translations file if needed: if the translations file hasn't been loaded.

Since:
FORMfields v3.0

setLanguage

public void setLanguage(string language)

Sets the current language.

Parameters:
language - the new language
Since:
FORMfields v3.0

setTranslationFilename

public void setTranslationFilename(string translationFilename)

Sets the translation filename and sets the translationsLoaded value to false.

Parameters:
translationFilename - the path to a translations file
Since:
FORMfields v3.0

translate

public mixed translate(mixed label)

Returns the translation(s) for the given label(s). If the $GLOBALS["FF_LANGUAGE_NATIVE_SHORTCUT"] is set to true then if the current language is the same as the native language then the label(s) are immediately returned. If not, the translation file is loaded, if not already loaded, and the appropriate translation(s) are returned according to the current language.

Parameters:
label - the label(s) to translate
Returns:
the translated label(s) according to the current language
Since:
FORMfields v3.0

translateLabel

public string translateLabel(string label)

Returns the translation for the given label. If the $GLOBALS["FF_LANGUAGE_NATIVE_SHORTCUT"] is set to true then if the current language is the same as the native language then the label is immediately returned. If not, the translation file is loaded, if not already loaded, and the appropriate translation is returned according to the current language.

Parameters:
label - the text to translate
Returns:
the translated text according to the current language
Since:
FORMfields v3.0

FORMfields