Домой Классы Статические функции Перечисления (ENUM) Структуры (STRUCTURE)


CLASS {Localize_str|ing_constants} , UNTESTED, BYTES, ABSTRACT :

To localize string constants in a class, it is necessary: 1. for each string constant (or string constant concatenation expression) apply a "function" _name, where name is a localization identifier for the string. E.g. _L1("This string is localizable") or "Localizable"._L1 (all these names must be unique in a class). 2. call in the application (in a function called on its initialization, e.g. in the main form CONSTRUCT) the method Localize. 3. A text file containing base (not translated) text is created either automatically in a default location, or by a call the method Save_untranslated (it is recommended to call it directly). Such file is named Default_.lng. Just copy it and rename copied file to Long_name_sn.lng (where Long_name - is a long name of your language and sn - is its short name). And replace desired original strings to translated. 4. To allow for a user to select a language for translating to it, get a list of available languages using the function Available_languages (returning the list as ';'-separated string), then use the string returned e.g. in a combo-box, then set new default current language calling the Set_language method. All translations are stored in text files looking like ini-files. Sections are rely to classes and are named in figure brackets. Each translation has a form name=value. ---------------------------------------- (C) 2017, by Vladimir Kladov

IMPORT : {String_functions} , {NATIVE_Localize_str} , {File_path} , {System_functions} , {File_stream} , {Memory_stream} , {Stream} .


FUNCTION Localize|_first_saves_untranslated_strings_when_called (
STR Lang|uage ,
STR Prefix|_in_names_Empty_to_replace_all ,
BOOL Write|_files_Default_etc )

FUN Localize_by|_translation_styrings (
STR Tr|anslation_strings [*] ,
STR Prefix|_in_names_Empty_to_replace_all )

FUNCTION Find_language_file|_LOCAL (
STR Lang|uage ,
STR Source|_directory ) ==> STR

FUNCTION Set_directory_lang|uage_files ( STR Dir|ectory_path )

FUNCTION Get_directory_lang|uage_files ==> STR

FUNCTION Save_untranslated|_strings (
STR Lang|uage_short_name ,
STR Language_name )



FUNCTION List_languages|_in_lng_files|semicolon_separated ==> STR


См. так же с защищёнными членами