Language variables serve as an essential tool for ensuring multi-language support for your Venddor IO modules. Instead of hardcoding texts, these variables offer flexibility to cater to various languages based on user settings.
Direct texts aren't embedded within PHP code or Smarty templates. Instead, a specific function retrieves the appropriate text based on the language variable provided. This function ensures the display of text matches the user's locale.
The translations for modules in Venddor IO are held in PO files. Each language possesses its dedicated PO file, categorized under its specific language code folder: var/langs/[language_code]/addons/[module_name].po.
For instance, the English translations for a module named "User Restrictions" would be stored at var/langs/en/addons/user_restrictions.po. Note that the PO file's name should align with the <id> content in app/addons/<module_name>/addon.xml.
When a module gets installed, Venddor IO scans its associated PO files. These variables are stored in the language_values table, comprising fields like lang_code, name, and value. These details are also mirrored to the original_values table.
During runtime, when a language variable is fetched for the first time through the __ function, it's sourced from the language_values table and then cached for swift subsequent retrievals. Any changes made by administrators in the Admin panel only modify the language_values table, preserving the original data in the original_values table.
Upgrading a module involves re-evaluating its PO files present in the upgrade package. While new language variables are incorporated, existing ones remain untouched. The same process applies during Venddor IO's platform upgrades.
On uninstalling a module, its associated PO files undergo a review, leading to the deletion of its language variables from both original_values and language_values tables. The language cache is also reset.
Modules in Venddor IO leverage these language variables to offer a dynamic, user-centric experience, adapting seamlessly across multiple languages. It promotes flexibility and a tailored approach, essential for a global audience.