• Localization
Search »

lang/[lang file].php

In most web applications you just embed the language strings directly in the PHP and HTML. This keeps everything nice and simple, but it limits the application to a single language. Form Tools supports displaying the same pages in multiple languages simultaneously to different users by storing all text strings in a separate language file. The files are found in the /global/lang/ folder, located in your Form Tools root.

Modules work in precisely the same way as the main script. They have their own lang/ folder where the language files should be placed . As a developer, you only need to write a single file in the language of your choice. This file contains a single associative array (hash) called $L containing all the language snippets that are used in your module. Here's an example (abbreviated) from the Export Manager module:

When you define this file in the same language as the Form Tools administrator, all the values in it are automatically made available to your PHP code and Smarty templates just by calling the ft_init_module_page() function in your module page, as mentioned above.

Here's a few more concrete details. Imagine you wanted to display the word "Action" on screen, you would first define that word in your language file like so:

You can then reference it in your template, using the $L variable, like this:

Or, to reference the value in your PHP, just reference the $L variable (defined in your global namespage), like so: $L["word_action"];

All other values from the Form Tools language file can be referenced with the $LANG global.

In addition to all the language snippets, your language file has two required hash keys:

These values are used on the Modules page to present information about the module (name & description) to the user in their chosen language.

As with the Form Tools main build, Form Tools automatically takes care of presenting modules in the language of the user. If the desired language file doesn't exist, it uses the module's default language.

Is all of this really necessary? I'm just writing this module for speakers of a single language...!

If you're not planning on publishing your module for others to use and just want to use it yourself, then no - none of this is necessary. Just define the file and include the two required keys (module_name and module_description). Then you can go about hardcoding the language strings directly in your templates & PHP.