This macro expression represents the string read from a text file
. The text file is in XML format, in UTF-8
character encoding and it is possible to store multiple texts in it. Each text can be entered in different nation language
. By means of this macro it is possible to easily create an application that can be switched into other languages while running (See also: How to create an application using different national languages
). The Macro expression is useful also in case of a single language application, if the texts of the application are located in one (or more) file(s).
This macro expression loads from the file the selected text accordig to its identifier and than according to the language:
- In local application:
the language of the text is choosen according to the current setting of the Pm.RtLang
property (according to the "Main language of runtime
- For Web clients:
the language of the Web component is choosen according to the language defined in the "PmaWeb > Web > Default language
" configurator. If the Web component is registered in the PmaWebLang
object, then the language is choosen according to the selected Web URL address.
macro expression can be used, for example, for setting the configurators PmgString > Text > Value
, PmaPanel > Panel > Panel title
and many others.
- idFile = the type of the XML file
- idText = user identifier of the text in this file
Obsolete syntax of macro expression:
The type of the XML file can be:
System file text_sys.xml
placed in the \Promotic\PmVXXYY
folder. This file is supplied together with the PROMOTIC system and some general texts can be found in it. It can also be used as an example of creating localized texts (but do not put your own texts into this file).
$.text("appXX","idText") - for example the text_appL1.xml file (if XX=L1) located in the application folder. This is just a generalization of the previous type in order to have the possibility to place multiple such files in the application folder.
Tip: The XML file can be created and edited by means of the configuration window, that can be opened from the menu " > Localized texts manager
The format of the XML file "text_XXX.xml":
There is only 1 tag <pmtext> in the XML file, there is the required number of <txtid> subtags with id attribute in this tag. The value of this attribute is the identifier of required text. There are <txt> tags with lang attribute in this tag, identifying the language version. The lang attribute may containt, for example, this value: en (English), de (German) ... For complete list see How to create an application using different national languages.
Example of the file content (the file does not have to include all stated language versions):
<?xml version="1.0" encoding="utf-8"?>
<txt lang="en">User text to set</txt>
<txt lang="de">Aplikationstext zum Einstellen</txt>
<txt lang="ru">Техт аппликации к наладке</txt>
<txt lang="pl">Tekst użytkownika do wprowadzenia</txt>
<txt lang="cs">Aplikační text k nastavení</txt>
<txt lang="sk">Aplikačný text k nastaveniu</txt>
Example of getting system localized text:
The text identified as "day1"
is saved in a file "text_sys.xml"
in the \Promotic\PmVXXYY
folder. The result of such procedure is having the text "Monday" for English, "Montag" for German language, etc.
Example of getting application localized text:
The designer of the application created the text_app.xml file in the application folder. There is a <txtid id="id10"> tag in that file and the <txt> subtag that corresponds to the current language version (e.g. en).
Example of obtaining the system text by using the Pmg object parameter (nDay):
Another option to get the localized text is to use Pm.EvalMacro
or #pragma variable
Configuration items in extended value editor:
|Select localized text||Opens the "Localized texts manager" configuration window|
|XML file type||Specifies text source file type, i.e. 1st parameter of the $.text() macro expression.|
|Text identifier||Specifies the identifier of desired text, i.e. 2nd parameter of the $.text() macro expression.|