Promotic

Macro expression $.text

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 according to its identifier and than according to the language:
- In the running 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" configurator).
- 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 to the selected URL address.


The $.text macro expression can be used, for example, for setting the configurators PmgString > Text > Value, PmaPanel > Panel > Panel title and many others.

Syntax:
$.text("idFile","idText")
- idFile = the type of the XML file
- idText = identifier of the text in this file

Obsolete syntax of macro expression: $text:idFile.idText

The type of the XML file can be:
$.text("sys","idText") - 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("app","idText") - the text_app.xml file located in the application folder (e.g. C:\Promotic\Apps\Application1\text_app.xml).


$.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 <pmtext> tag 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"?>
<pmtext>
...
<txtid id="id10">
  <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>
</txtid>
...
</pmtext>


Example of getting system localized text:
$.text("sys","day1")
The text with day1 identifier is saved in the text_sys.xml file 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:
$.text("app","id10")
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):
$.text("sys",$.join("day",$.par("nDay")))


Another option to get the localized text is to use Pm.EvalMacro or #pragma variable.
Configurators in extended value editor:
Select localized textOpens the "Localized texts manager" configuration window
XML file typeSpecifies text source file type, i.e. 1st parameter of the $.text() macro expression.
Text identifierSpecifies the identifier of desired text, i.e. 2nd parameter of the $.text() macro expression.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.