-
Notifications
You must be signed in to change notification settings - Fork 0
WD ATTR Translate Tool
The reference for how the attribute works is in the following tools:
The attribute's destination is indifferent and can be applied to any element.
The attribute has the following arguments:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| path | String | Yes | Directory containing the files with the translation configuration. |
| method | String | No | Request method (POST/GET), see send. |
| main | String | No | Alternative file name in case the defined ones are not found. |
For dynamic assignments, see:
The specified directory must contain the configuration files for the translation to be applied. The file name must be the same as the language followed by the .json extension, all in lower case.
For example, having the result en-US as the language, initially the script will try to locate the file with the complete description of the language, that is, en-us.json. If it does not find it, it will try to locate the file corresponding to the language base, ie en.json. If it is not found and if the alternative JSON file is informed, an attempt will be made to locate the alternative file located in the same directory. If none of the files are found, nothing is done.
The language definition will be given by the lang HTML attribute. The search for information will start with the element that contains the data-wd-translate attribute and will continue through the parent elements until it finds an assigned value. If not found, the value informed by the browser will be used.
The structure of the JSON file must be composed of an array of objects whose keys refer to the attributes to be updated by the respective content. There are two special keys, $ and $$, which must contain the CSS selector that represents the element or elements that will receive the values of the other keys, as shown in the example below:
[
{
"$$": ".text",
"textContent": "Textual contents of elements that contain the \"text\" class attribute.",
"title": "Value of the \"title\" attribute of elements that contain the \"text\" class attribute."
},
{
"$": "#head",
"textContent": "Textual content of elements containing the identified \"head\"."
}
]<body data-wd-translate="path{files/lang}main{default.json}">
<h1 id="head">Header</h1>
<p class=".text">Default content.</p>
</body>- WD Web Libraries | v4.4.4 | 2023-02-22
- Updated on 2023-02-22
- WD JS Array Tools
- WD JS Date Tools
- WD JS DOM Tools
- WD JS Number Tools
- WD JS Text Tools
- WD JS Time Tools
- WD ATTR Chart Tool
- WD ATTR Click Tool
- WD ATTR CSS Tool
- WD ATTR Data Tool
- WD ATTR Device Tool
- WD ATTR Edit Tool
- WD ATTR Filter Tool
- WD ATTR Full Tool
- WD ATTR Jump Tool
- WD ATTR Lang Tool
- WD ATTR Load Tool
- WD ATTR Mask Tool
- WD ATTR Nav Tool
- WD ATTR NoBubbles Tool
- WD ATTR Output Tool
- WD ATTR Page Tool
- WD ATTR Repeat Tool
- WD ATTR Send Tool
- WD ATTR Set Tool
- WD ATTR Shared Tool
- WD ATTR Slide Tool
- WD ATTR Sort Tool
- WD ATTR Tsort Tool
- WD ATTR Translate Tool
- WD ATTR URL Tool
- WD ATTR Vform Tool