|
| 1 | +# 🌐 Plugin localization |
| 2 | + |
| 3 | +## Using the localization string |
| 4 | + |
| 5 | +Anywhere in the plugin code, this call: |
| 6 | + |
| 7 | +```javascript |
| 8 | +_T('LocalizationKey'); |
| 9 | +_T('LocalizationKey', { dynamicValue: 'test'}); |
| 10 | +``` |
| 11 | + |
| 12 | +**\_T** will print the value of the localization key **LocalizationKey**. If the value is missing, the key name will be printed with underscores \_LocalizationKey\_ (in markdown output, it will be displayed in italics without underscores - _LocalizationKey_). |
| 13 | + |
| 14 | +The second parameter (object) is used to pass dynamic values that can be inserted into the string. |
| 15 | + |
| 16 | +The chapter 🌐 [New language for Viewer][ViewerNewLang] further describes: |
| 17 | + |
| 18 | +- the structure and meaning of the main localization files, |
| 19 | +- their location, |
| 20 | +- the format of localization keys, which is automatically mapped to HTML objects according to the match between the id and property name and the key name. |
| 21 | + |
| 22 | +## Separate localization dictionary for the plugin |
| 23 | + |
| 24 | +Using the 🧩 [pServiceLocalization][pServiceLocalization] plugin (part of the basic package), you can add your own localizations for each plugin. Just create the appropriate files in the right place. |
| 25 | + |
| 26 | +Required files: |
| 27 | + |
| 28 | +- **lstr.txt** – fixed texts |
| 29 | +- **lstr.js** – dynamic strings (contain variables, compose texts on the fly) |
| 30 | + |
| 31 | +Structure |
| 32 | + |
| 33 | +- Files are stored according to language codes (cs, en, ...). |
| 34 | +- The directory tree for each language is shown in the following chapters. |
| 35 | +- 🛈 The browser data and help data directory trees differ because they are based on different internal loading processes. |
| 36 | + |
| 37 | +Further information |
| 38 | + |
| 39 | +- A detailed description of the structure and format of localization files can be found in the chapter 🌐 [New language for Viewer][ViewerNewLang]. |
| 40 | + |
| 41 | +Description of activity |
| 42 | + |
| 43 | +- When a plugin instance is loaded, its localization dictionary is loaded from the relevant files and added to the already loaded localization. |
| 44 | +- When changing the language, the main localization dictionary is loaded first, followed by the dictionaries according to the [loading order][OELoadOrder] of the individual plugin instances. |
| 45 | +- In case of key name collisions, the last loaded value takes precedence, as it overwrites all previous ones. |
| 46 | + |
| 47 | +### In browser data |
| 48 | + |
| 49 | +```treeview |
| 50 | +HelpViewer/ |
| 51 | + zip/ |
| 52 | + plugin-class-name/ |
| 53 | + cs/ |
| 54 | + lstr.js |
| 55 | + lstr.txt |
| 56 | + en/ |
| 57 | + lstr.js |
| 58 | + lstr.txt |
| 59 | +``` |
| 60 | + |
| 61 | +### In help data |
| 62 | + |
| 63 | +```treeview |
| 64 | +helpProject/ |
| 65 | + cs/ |
| 66 | + plugin-class-name/ |
| 67 | + lstr.js |
| 68 | + lstr.txt |
| 69 | + en/ |
| 70 | + plugin-class-name/ |
| 71 | + lstr.js |
| 72 | + lstr.txt |
| 73 | +``` |
| 74 | + |
| 75 | +[ViewerNewLang]: newLangViewer.md#h-3-1 "New language for Viewer" |
| 76 | +[pServiceLocalization]: :_plg:pServiceLocalization.md "pServiceLocalization" |
| 77 | +[OELoadOrder]: :_/LORDER.md "Loading order" |
0 commit comments