TranslateUnitResourceStringsEx function
Translates string constants in a unit using the localization file for the specified language and path.
Declaration
function TranslateUnitResourceStringsEx(Lang: string; Dir: string;
LocaleFileName: string;
LocaleUnitName: string='')
: stringArguments
Lang | Optional language identifier requested for the translation. |
Dir | Optional path to the localization files used in the translation. |
LocaleFileName | Base name for the localization file used in the translation. |
LocaleUnitName | Optional base name of the unit with strings translated in the routine. |
Function result
The language code or locale ID used in the translation, or an empty string when a translation is not available or an error has occurred.
Description
TranslateUnitResourceStringsEx is a convenience routine used to
translate string constants in a specified source file to a given language. It
provides arguments which identify the source file, the path to localization
files, and the language requested.
Lang contains the optional language identifier requested for the
translated string constants. It contains a value like 'en', 'ru' or 'de'. An
empty string (
'') causes the default language identifier for the
platform or operating system to be used.
Dir contains the path where the localization files (.po, .mo) are
located. It can contain a path relative to the directory for the application
executable, or a fully qualified path to the directory with the localization
files. For example: 'languages' or '/usr/share/locale'. An empty string
(
'') indicates that the predefined directories like 'languages' or
'locale' are used to locate the localization files.
LocaleFileName contains the base name for the localization file
used to translate the values in the specified unit. It contains a value like
'lazaruside' or 'lclstrconts'. No actions are performed in the routine when
LocaleFileName is an empty string ('').
LocaleUnitName contains the base name for the source code file
with the string constants translated in the routine. An empty string
(
'') causes the value in LocaleFileName to be used as the base source
code file name.
TranslateUnitResourceStringsEx calls the FindLocaleFileName implementation routine to resolve the requested language identifier, and the path and file extension for the localization files. .po files are given preference, and .mo files are used when a .po equivalent is not available.
TranslateUnitResourceStringsEx calls the TranslateUnitResourceStrings routine
in the translations.pp unit to translate the specified file
using the path to the localization file.
TranslateUnitResourceStringsEx calls the TranslateResourceStrings routine in
the FCL gettext.pp unit to translate using a .mo file when a
path to .po files is not found.
The return value contains the language code or locale ID used in the translation. An empty string ('') in the return value indicates that a localization file for the specified arguments was not found, or that an error occurred during the translation.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
