Languages
TreeGrid documentation
Language and regional settings (Text.xml)
All TreeGrid texts, messages, alerts and language dependent settings are stored in
Text.xml.
You can translate this file to all languages you need and provide to visitors appropriate file according to their language settings.
Url to Text.xml is set by
<treegrid/bdo Text_Url/>
In
Text.xml are the attributes marked according to TreeGrid version in which were added.
The most of language settings is set in <Lang> tag, the rest in <Toolbar>, <Panel> and <Header>.
You can define or redefine any particular or even all settings outside the Text.xml in any other input XML, in appropriate tags.
For example to change text for deleting row set
<Lang><Alert DelRow='Do you want to delete the row %d ?'/></Lang>
<Lang>
<Alert>
XML tag
All pure text settings. Used for standard
alert and
confirm dialogs.
If the particular text is set to empty string, the message is
not shown and the confirm dialog returns true or false according to particular logic.
The message can contain some variable information like row or column name, count of rows and so on. This information replaces the
%d or
%1,
%2, etc. string in the message.
If there are more variable information, they replace one by one the
%d strings in the message.
What message can contain variable information you can see from its text in
Text.xml.
<Lang>
<Text>
XML tag
All HTML texts in grid. Usually text of
status messages displayed in grid.
If the particular text is set to empty string, the message is
not shown.
The message can contain some variable information like row or column name, count of rows and so on. This information replaces the
%d string in the message.
If there are more variable information, they replace one by one the
%d or
%1,
%2, etc. strings in the message.
What message can contain variable information you can see from its text in
Text.xml.
new 6.0 <Lang>
<Gantt>
XML tag
Gantt chart texts, the same syntax as <
Text>.
new 12.0 <Lang>
<MenuCell>
XML tag
All action texts in cell popup menu.
If the particular text is set to empty string, the item is
not shown.
The message can contain some variable information like row or column name, count of rows and so on. This information replaces the
%d string in the message.
If there are more variable information, they replace one by one the
%d or
%1,
%2, etc. strings in the message.
What message can contain variable information you can see from its text in
Text.xml.
new 6.0 <Lang>
<MenuButtons>
XML tag
Popup dialog buttons, for menu and calendar. Pure texts.
new 6.0 deleted 12.0 <Lang>
<MenuCopy>
XML tag
All possible items in popup Copy / Add menu.
Replaced by <MenuCell>
<Lang>
<MenuCfg>
XML tag
All item names in options menu.
new 12.1 <Lang>
<MenuColumns>
XML tag
All item names in columns menu.
new 12.1 <Lang>
<MenuPrint>
XML tag
All item names in print menu.
new 12.1 <Lang>
<MenuExport>
XML tag
All item names in export menu.
<Lang>
<MenuFilter>
XML tag
All operator names in
Filter operator menu.
<Lang>
<Format>
XML tag
All language settings for formatting date, time and numbers.
Contains predefined formats and item names (like day or month names).
Predefined formats are global for whole page, for all grids on one page.
For attribute description see
Number localization and
Date localization.
new 14.0 <I> bool
TextOnly
Used for defining some fixed row attributes in Text.xml to not affect the row position.
Define the row with TextOnly in Text.xml also with Visible='0' and in data or layout redefine the row with the same id and Visible='1'.
For example in Text.xml define the row text as:
<Solid><I id='MyRow' Visible='0' TextOnly='1' MyCol='MyTextToTranslate'/></Solid>
And in data or layout define the row normally with all attributes, like:
<Solid><I id='MyRow' Visible='1' Cells='MyCol' MyColWidth='100' ... /></Solid>
new 6.0 <Toolbar cell> string
Tip
Tooltip texts for all standard Toolbar buttons
new 6.0 <Panel> string
PanelxxxTip
xxx is name of Panel button like Select
Tooltip texts for all standard Panel buttons
new 6.0 renamed 12.0 <Header> string
PanelPanelxxxTip
xxx is name of Panel button like Select
Tooltip texts for all standard Panel buttons in header.
Since 12.0 it was renamed from PanelHeaderxxxTip.
API variable object
Lang
Actual language settings loaded from <Lang> tags.
Translate texts
Definitions of cell texts or text parts to be replaced by another string for given language.
The text is translated only for display. In data it still contains original values.
The texts are set / replaced in order they are defined and the language files loaded.
Only the texts defined in one tag (including nested <U> tags) are replaced in order from the longest to the shortest.
new 14.0 <Grid>
<TextXX>
XML tag
Defines translations for language XX, where XX is the language
Code.
new 14.0 <TextXX>
<T>
XML tag
Definition of one translate action.
As shortcut the T can be replaced by the action name
<T Action="Set" ... is the same as
<Set ...
new 14.0 <T> string
Action
Action used for translation, case insensitive. It can be:
Set - set texts directly to the column values. The other attributes are defined as ColName="translated value". There is no Col attribute.
Change - replace the whole cell value by the text. The other attributes are defined as value_to_translate="translated value" or the child tag as <U N="value to translate" V="translated value"/>
Replace - replace the part of the text value by the text. Case sensitive, only the first occurrence. The other attributes are defined as value_part_to_translate="translated value part" or the child tag as <U N="value part to translate" V="translated value part"/>
Last - the same as
Replace, but replaces the last occurrence instead of first one.
Regex - replace the part of the text value by RegEx by the text. Case insensitive, all occurrences (regex "gi"). The child tags are defined as <U N="regex to translate" V="translated value part"/>
Set and
Change are fast,
Replace and
Regex are slower and should be used only if the Set and Change cannot be used.
Action can be set also directly to the tag name:
<T Action="Set" ... is the same as
<Set ...
Action can end with "Text" (
SetText,
ChangeText,
ReplaceText,
LastText,
RegexText) to replace only text part in HTML value. Using Text suffix slows down the translation.
new 14.0 <T> string
Row
Row id to apply the translation to. If set, the Def, Kind and Space is ignored. It can be also comma separated list of more row ids.
The Row can be set also to the keyword:
- "
MenuName" to change column caption in visibility menu,
- "
SearchNames" to change column captions for search,
- "
Header" to change pager caption (
Col is set to the pager
Name).
new 14.0 <T> string
Def
Row default name to apply the translation to. If set, the Kind and Space is ignored. It can be also comma separated list of more row default names.
new 14.0 <T> string
Kind
Row kind it to apply the translation to. If set, the Space is ignored. It can be also comma separated list of more row kinds.
new 14.0 <T> bool
Space
If set, the translation is applied to solid rows, otherwise it is applied to data or fixed rows.
new 14.0 upd 16.1 <T> string
Col
Column name to apply the translation to. If set, the Type is ignored. It can be also comma separated list of more columns.
The Col can be set also to the keyword:
- "
MenuName" to change row name in visibility menu,
- "
GanttXXX
Tip to change Gantt item tip before it is converted. To translate converted Gantt tip use Gantt column name plus "Tip" instead.
The XXX can be
empty (first main bar),
number (other plan main bars),
Milestone,
Milestonenumber,
Run,
Dependency,
Constraints,
Points,
Flags,
Base,
BaseAuto,
Finish,
FinishAuto,
LineX,
Line.
- "
GanttXXX
Text to change Gantt item text before it is converted. To translate converted Gantt text use Gantt column name plus "Text" instead.
The XXX can be
empty (first main bar inside text),
number (other plan main bars),
Left (first main bar left side text),
Leftnumber (other plan main bars),
Right (first main bar right side text),
Rightnumber (other plan main bars),
Run (run inside text),
RunLeft (run left side text),
RunRight (run right side text),
Mark (GanttMark text),
Flags (GanttFlags text).
The Col can be set also to:
- column or cell name plus "
Menu" to translate anything in column popup menu for given Row or all rows. If set only as Menu, it translates it in all columns's menus.
-
since 16.1 "Choose..." action name plus "
Menu" to translate the popup menu shown by the Choose... action.
- column or cell name plus "
MenuHead" to translate head section in column popup menu for given Row or all rows. If set only as MenuHead, it translates it in all columns's menus.
- column or cell name plus "
MenuFoot" to translate foot section in column popup menu for given Row or all rows. If set only as MenuFoot, it translates it in all columns's menus.
- column or cell name plus "
FilterMenu" to translate anything in filter cell popup menu for given Row or all rows. If set only as FilterMenu, it translates it in all columns's menus.
- column or cell name plus "
Edit" to change edited value - reversed translation from destination language to source language.
- column or cell name plus "
Tip" to change cell tip, including all converted Tip in Gantt except drag tip,
- column or cell name plus "
Fix" to change cell value with HtmlPrefix and HtmlPostfix,
- column name plus "
DragTip" to change Gantt drag tip,
- column name plus "
Text" to change any Gantt item text.
- cell name plus "
Label" or
"LabelRight" to change cell label in solid space row.
- pager
Name to change Pager caption, the
Row must be set to "Header".
new 14.0 <T> string
Type
Column type to apply the translation to. It can be also comma separated list of more types.
If set neither Type nor Col, the translation Action "Set" is applied to all defined column attributes, other Actions are applied to all row cells.
new 15.0 <T> int
Count
Can be set to 1 - 5 to permit more destinations for the same translated values.
If set, the tag can have defined also attributes RowN, ColN, DefN, KindN, TypeN, SpaceN, ActionN, where N is number 1 - 5.
new 14.0 <T> <U> string
N
Attribute name if it contains characters like space and cannot be used as XML attribute name.
new 14.0 <T> <U> string
V
Value of attribute
N.
new 14.0 <T>
<U>
XML tag
Child tags of <T> to define attributes those names contain characters like space and cannot be used as XML attribute name.
new 14.0 API method string
Translate
(TRow row, string col, string text, string type)
Translates given
text in given cell to actual language.
new 14.0 API event string
OnTranslate
(TGrid grid, TRow row, string col, string text, string type)
Called before the
text is translated to the actual language. Return the translated text.
Called from
Translate method.
new 14.0 API event string
OnTranslated
(TGrid grid, TRow row, string col, string text, string type)
Called after the
text is translated to the actual language. Return the translated text.
Called from
Translate method.
Changing language
TreeGrid can change its language and translate all its texts without reloading the whole grid.
new 14.0 <Cfg> string
Language
Saved to cookies except if set LanguageLap='1'
Language code actually used in TreeGrid. It is the
Code of one of defined languages in <Languages> tag.
new 14.0 <Cfg> string[]
UseLanguages
Comma separated list of language codes to display in popup menu to select language.
Use it to specify order and / or subset of defined languages to let users to choose from.
It can contain item "-" as separator or item "-xxx-" as caption xxx.
new 14.0 <Cfg> int
LanguagesColumns
[1]
If set, it splits large languages menu to given number of columns.
new 14.0 <Cfg> string
SyncLanguage
[1]
Synchronizes Language and UseLanguages among all grids with the same value of SyncLanguage.
By default it is 1 for all grids to synchronize language among all grids.
new 15.0 <Cfg> int
Reset
[0]
Which features will be reset to defaults, bit array.
1. bit - &
1 - Cfg Style, CSS and DialogCSS.
2. bit - &
2 - Cfg GanttStyle and GanttCSS.
3. bit - &
4 - Cfg Language.
Set it in Defaults.xml if bundled inside GridE.js with only one CSS style and / or one language.
If set, it will always use the settings in Defaults.xml and will ignore all settings in other files and restrict changing the values.
For example it is set to 3 in
GridEStandalone.js to reset styles, because it contains only Standard grid style and White Gantt style, but all languages.
new 14.0 <Languages>
<L>
XML tag
Definition of one language. As shortcut the L can be replaced by the language code
<L Code="EN" ... is the same as
<EN ...
new 14.0 <L> string
Code
Standard two letter language code like "EN", "FR" or "DE". Case insensitive, for API always converted to upper case.
It is used to identify the language, to be set to the
Language
Can be set also directly to the tag name:
<L Code="EN" ... is the same as
<EN ...
It can be also comma separated list of language codes to set more languages at once.
It can be also "
*" to set all already present languages.
It can be also "
-XX" to set all already present languages except the language XX, for example Code="-EN".
new 14.0 <L> string
Name
Name of the language. It is shown in popup menu to select language.
new 14.0 <L> string[]
Source
["Text,Base,Layout,Data,Lang"]
Comma separated list of data sources to load for given language.
Similar to <treegrid>
Source attribute. But the sources here are always loaded one by one.
If the source name is the same as existing data source defined in <treegrid>
Source attribute,
it uses all its attributes from the original data source and is loaded only if contains different url or other attributes than the original source.
The data source can define all standard data source attributes like xxx_Url or xxx_Param, see
Data communication.
Default data sources for language are
Text,
Base,
Layout,
Data as standard data sources except Defaults and special data source for languages
Lang.
new 14.0 <L> string
Tip
Since 14.0.10. Tip shown for the language in popup menu.
new 14.0 API method bool
SetLanguage
(string code)
Changes grid
Language to the
code, loads all language resources and re-renders grid.
Returns true if language was set synchronously, false when loading language files asynchronously and null for not existing language.
new 14.0 API event bool
OnSetLanguage
(TGrid grid, string code, bool sync)
Called before the grid language is set to given
code. Return true to suppress changing the language.
Called from
SetLanguage method.
sync is true if called from next grids due language synchronization.
new 14.0 API event void
OnLanguageSet
(TGrid grid, string code, bool sync)
Called after the grid language is set to given
code and all language resources are loaded to grid. Called before the grid is re-rendered.
Called from
SetLanguage method.
sync is true if called from next grids due language synchronization.
new 14.0 API event void
OnLanguageFinish
(TGrid grid, string code, bool sync)
Called after the grid language is set to given
code and all language resources are loaded to grid and the grid is re-rendered.
Called from
SetLanguage method.
sync is true if called from next grids due language synchronization.