Internationalisation (LAN)

Introduction

Your website can be used in different languages. In order for your plugin or theme areas to be displayed in a specific language, it needs to be translated.

Language files

File Types

There are three types of language files that can be used in your plugin.

Language File

Usage

English_front.php

Used only for the frontend of your plugin

English_admin.php

Used only for the Admin Area of your plugin

English_global.php

Used site-wide, for example in πŸ‘‰ plugin.xml, files such asxxxx_menu.phpor πŸ‘‰ addons.

Defining Language Terms

Language Terms are more commonly known as LAN's. You can define LAN's by using PHP constants:

define("LAN_PLUGIN_MYPLUGIN_NAME", "Blank Plugin");
define("LAN_PLUGIN_MYPLUGIN_DIZ",  "A Blank Plugin to help you get started in plugin development. More details can be added here."); 
define("LAN_PLUGIN_MYPLUGIN_LINK", "Blank Link");

Best practices

πŸ‘ Always use the format LAN_PLUGIN_{FOLDER}_{TYPE} to prevent conflicts.

Avoid duplicating terms, particularly in the admin area.

πŸ‘ If defining terms for admin, always search lan_admin.php for existing LANs which may match what you require.

Never use HTML or URLs inside LAN definitions.

πŸ‘ Use double quotes within the defines and use str_replace() or πŸ‘‰ lanVars() for variables where needed.

Avoid short language strings for common words

Examples are words such as 'and', 'to' and so on. There aren't always equivalents in other languages.

πŸ‘ If embedding values into a phrase, use substitution.

Avoid using substitution terms which are real words or known BBCodes.

πŸ‘ Use brackets [..] and values such as x, y, z. See examples below.

Examples

Good

Bad

Substitution

Loading Language Files

e107::lan()

To load a language file from a plugin folder, use e107::lan():

This will include the following paths:

Last updated

Was this helpful?