About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


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.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:architecture:localization [2023/08/17 20:11] demiankatzdevelopment:architecture:localization [2024/01/10 13:56] (current) – [Translate Function] demiankatz
Line 12: Line 12:
  
   * 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 tokens (i.e. "adv_search_filters").  The token approach is often preferable since it allows for more concise map files and reduces the chances of conflicts where the same text has multiple meanings.+  * Many of the translated strings in the language files are simply chunks of English text.  However, more recent additions are represented as shorter abstract keys (i.e. "adv_search_filters").  The abstract key approach is often preferable since it allows for more concise map files and reduces the chances of conflicts where the same text has multiple meanings.
   * Starting with VuFind® 2.4, a convenient [[https://github.com/vufind-org/vufind/blob/dev/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareTrait.php|TranslatorAwareTrait]] has been added which adds VuFind®'s standard translation capabilities to any object. Use it in combination with the [[https://github.com/vufind-org/vufind/blob/dev/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareInterface.php|TranslatorAwareInterface]] to have the translator object automatically injected.   * Starting with VuFind® 2.4, a convenient [[https://github.com/vufind-org/vufind/blob/dev/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareTrait.php|TranslatorAwareTrait]] has been added which adds VuFind®'s standard translation capabilities to any object. Use it in combination with the [[https://github.com/vufind-org/vufind/blob/dev/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareInterface.php|TranslatorAwareInterface]] to have the translator object automatically injected.
 +  * 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. <nowiki>%%token%%</nowiki>) 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://github.com/vufind-org/vufind/pull/3286|pull request #3286]] for details and examples.
  
 ===== Formatting Language Files ===== ===== Formatting Language Files =====
Line 47: Line 48:
 Note also that there are [[administration:command_line_utilities#language_category|language-related command line utilities]] which can help with common maintenance tasks. Most importantly, rather than manually sorting your language files, you can add new/missing strings to the ends, and rely upon the "language normalize" tool to put everything in correct order and format files to project standards. Note also that there are [[administration:command_line_utilities#language_category|language-related command line utilities]] which can help with common maintenance tasks. Most importantly, rather than manually sorting your language files, you can add new/missing strings to the ends, and rely upon the "language normalize" tool to put everything in correct order and format files to project standards.
  
 +If you want to contribute to the project's translations without modifying code or files, you can also request access to our [[development:architecture:localization:lokalise|Lokalise]] instance.
 ===== Customizing Language Files ===== ===== Customizing Language Files =====
  
Line 139: Line 141:
  
 Starting with VuFind® 9.1, if you activate the "debug" language code in the [Languages] section of config.ini, you can put the software into a mode that will display all of the raw data used in translation, instead of actually applying the translation system. This can be helpful for identifying which strings in the language files need to be overridden to customize particular parts of the interface and for troubleshooting problems. Starting with VuFind® 9.1, if you activate the "debug" language code in the [Languages] section of config.ini, you can put the software into a mode that will display all of the raw data used in translation, instead of actually applying the translation system. This can be helpful for identifying which strings in the language files need to be overridden to customize particular parts of the interface and for troubleshooting problems.
 +
 +===== Related Links =====
 +
 +  * [[community:language_support_list|Language Support List]] - a list of volunteers who help with the project's localization (and unclaimed languages which need volunteers).
  
 ===== Video ===== ===== Video =====
development/architecture/localization.1692303066.txt.gz · Last modified: 2023/08/17 20:11 by demiankatz