Translate strings

Helper class to translate strings.

This documentation refers to SuiteCRM version 7.10.3 onwards

Usage

// example string definition (only for understanding the next examples):
$app_strings['LBL_EXAMPLE_APP_STR'] = 'Example Application String';
$mod_strings['LBL_EXAMPLE_MOD_STR'] = 'Example string for a specified module';
$mod_strings['LBL_EXAMPLE_VARIABLE'] = 'Example string to use value of {foo}';


// Using translation for any strings
$text = new LangText('LBL_EXAMPLE_APP_STR');
echo $text;

// Using translation for any strings with replaced strings values
$text = new LangText('LBL_EXAMPLE_VARIABLE', ['foo' => 'bar']);
echo $text; // output: Example string to use value of bar

// Using translation only for Module Strings
$text = new LangText('LBL_EXAMPLE_MOD_STR', null, LangText::USING_MOD_STRINGS);
echo $text;

// Using translation only for Application Strings
$text = new LangText('LBL_EXAMPLE_APP_STR', null, LangText::USING_APP_STRINGS);
echo $text;

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.