Using language files


Introduction

You may have previously read about config variables or language variables in the OFW template syntax documentation. Below is a more detailed explanation of how you can use language files and language variables to localize your templates and system messages.

Quick rundown

Language files are a way to store locale-based information in structured key/value pairs. The format is standard ini. Here’s how to create them:

  1. Create files for all your supported locales, for example /lang/user.en_US.lang.ini
  2. Add all the sections and variables to the ini file
  3. Where needed, load the language file: $this->zajlib->lang->load('user');. The file of the current locale will be loaded automatically. You can also load language files in templates: {% lang 'user' %}
  4. You can also load a specific section with $this->zajlib->lang->load('user', 'my_section'); or {% lang 'user' 'my_section' %}
  5. Then just use the variables: {{#a_language_variable#}} in a template or
    $this->zajlib->lang->variable->a_language_variable in php code

Now let’s dive deep into the details!

Outlast Web & Mobile Development (c) 2023 | Privacy Policy |