Warning: This page has not been updated in over over a year and may be outdated or deprecated.
development:architecture:localization
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
development:architecture:localization [2019/03/07 13:44] – [Formatting Language Files] demiankatz | development:architecture:localization [2024/01/10 13:56] – [Translate Function] demiankatz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Language Support ====== | ====== Language Support ====== | ||
- | |||
- | // This page refers to VuFind 2.x and later; use of earlier versions is no longer recommended. // | ||
Keywords: localization, | Keywords: localization, | ||
- | VuFind | + | VuFind® |
===== Translate Function ===== | ===== Translate Function ===== | ||
- | VuFind | + | VuFind® |
Notes: | Notes: | ||
* If you attempt to translate a string that is not found in a language map, the original string will be displayed untranslated. | * If you attempt to translate a string that is not found in a language map, the original string will be displayed untranslated. | ||
- | * Many of the translated strings in the language files are simply chunks of English text. However, more recent additions are represented as shorter | + | * Many of the translated strings in the language files are simply chunks of English text. However, more recent additions are represented as shorter |
- | * Starting with VuFind | + | * Starting with VuFind® |
+ | * The translate function can accept an array of values to insert into the translation string in order to include variables inside the translation (e.g. numbers). Placeholders for values are generally surrounded by double-percent-signs (e.g. %%token%%) in the language files. Starting with VuFind® 10.0, an additional argument can be added to the translate function to override the simple search-and-replace value insertion mechanism with the more complex ICU MessageFormatter syntax. When using MessageFormatter syntax, placeholders use braces instead of percent signs. See [[https:// | ||
- | ==== Formatting Language Files ==== | + | ===== Formatting Language Files ===== |
When modifying an existing language file or creating a new one, you should observe these standards: | When modifying an existing language file or creating a new one, you should observe these standards: | ||
- | * Save the file in UTF-8 format without a Byte Order Marker (BOM). | + | * Save the file in UTF-8 format without a Byte Order Marker (BOM). |
- | * Make sure the file is sorted in a case-insensitive manner; | + | * Make sure the file is sorted in a case-insensitive manner; |
* Put double-quotes around multi-word phrases on the right side of the equals sign. Do NOT put quotes around phrases on the left side of the equals sign. | * Put double-quotes around multi-word phrases on the right side of the equals sign. Do NOT put quotes around phrases on the left side of the equals sign. | ||
- | For an example of a full language file, see [[https:// | + | For an example of a full language file, see [[https:// |
:!: Note: If modifications to a language file do not take effect, sometimes it is necessary to clear out the local directory language cache by removing the local/ | :!: Note: If modifications to a language file do not take effect, sometimes it is necessary to clear out the local directory language cache by removing the local/ | ||
- | === Sorting Language Files === | + | ==== Sorting Language Files ==== |
To sort a directory full of language files, simply go to the command line, and from your $VUFIND_HOME directory, run: | To sort a directory full of language files, simply go to the command line, and from your $VUFIND_HOME directory, run: | ||
Line 35: | Line 34: | ||
php public/ | php public/ | ||
| | ||
- | VuFind | + | VuFind® |
- | ==== Adding a New Language ==== | + | ===== Adding a New Language |
- | - Create a new language file as described [[# | + | - Create a new language file as described [[# |
- If you also wish to translate strings inside text domains (see below) you will need to create appropriate subdirectories inside languages, and put additional language files inside these directories. | - If you also wish to translate strings inside text domains (see below) you will need to create appropriate subdirectories inside languages, and put additional language files inside these directories. | ||
- If desired, translate help screens as described [[#help screen translation|above]]. | - If desired, translate help screens as described [[#help screen translation|above]]. | ||
- Edit [[configuration: | - Edit [[configuration: | ||
+ | ===== Updating a Language ===== | ||
- | ==== Customizing | + | If you wish to maintain an existing set of language files, but you are not sure which strings have been recently added, VuFind® includes a language tool which will generate lists of missing strings in all supported languages. To access it, turn on [[development: |
- | If you need to customize the language files residing in VUFIND_HOME/languages but do not want to commit this customization | + | Note also that there are [[administration: |
- | Starting with VuFind | + | If you want to contribute to the project' |
- | === Defining an Explicit Parent Language File === | + | ===== Customizing Language Files ===== |
+ | |||
+ | If you need to customize the language files residing in VUFIND_HOME/ | ||
+ | |||
+ | Starting with VuFind® | ||
+ | ==== Defining an Explicit Parent Language File ==== | ||
In addition to the above mentioned implicit inheritance of language .ini files VuFind\Il8n\Translator offers a similiar feature as the configuration .ini file's [Parent_Config] section: by adding the line @parent_ini = " | In addition to the above mentioned implicit inheritance of language .ini files VuFind\Il8n\Translator offers a similiar feature as the configuration .ini file's [Parent_Config] section: by adding the line @parent_ini = " | ||
- | == Example 1 == | + | === Example 1 === |
* language is set to " | * language is set to " | ||
Line 64: | Line 69: | ||
The content of vufind2/ | The content of vufind2/ | ||
- | == Example 2 == | + | === Example 2 === |
Using customized language files for a multisite-setup. | Using customized language files for a multisite-setup. | ||
Line 102: | Line 107: | ||
- | ==== Text Domains ==== | + | ===== Text Domains |
- | Starting with VuFind | + | Starting with VuFind® |
For example, suppose you added: | For example, suppose you added: | ||
Line 115: | Line 120: | ||
$translator-> | $translator-> | ||
+ | |||
+ | or | ||
+ | |||
+ | $translator-> | ||
on a valid $translator object would return "The translation" | on a valid $translator object would return "The translation" | ||
- | Text domains currently used by VuFind: | + | Text domains currently used by VuFind®: |
+ | * CallNumberFirst - used for translation of main classification category | ||
* CreatorRoles - used for translating author relator terms (such as [[https:// | * CreatorRoles - used for translating author relator terms (such as [[https:// | ||
* HoldingStatus - used for displaying complex item availability messages (not supported by all ILS drivers) | * HoldingStatus - used for displaying complex item availability messages (not supported by all ILS drivers) | ||
+ | * Exception - used for exception messages (currently not the exclusive location for these kinds of messages, but refactoring may eventually occur) | ||
+ | |||
===== Help Screen Translation ===== | ===== Help Screen Translation ===== | ||
- | VuFind's help screens contain too much text for the standard translation mechanism to be a practical way of presenting them in multiple languages. | + | VuFind®'s help screens contain too much text for the standard translation mechanism to be a practical way of presenting them in multiple languages. |
+ | |||
+ | ===== Troubleshooting Language Strings ===== | ||
+ | |||
+ | Starting with VuFind® 9.1, if you activate the " | ||
+ | |||
+ | ===== Related Links ===== | ||
+ | |||
+ | * [[community: | ||
+ | |||
+ | ===== Video ===== | ||
+ | This topic is discussed in the [[videos: | ||
---- struct data ---- | ---- struct data ---- | ||
+ | properties.Page Owner : | ||
---- | ---- | ||
development/architecture/localization.txt · Last modified: 2024/01/10 13:56 by demiankatz