Language Packs: Getting Started
Learn about what a language pack is, the basic structure and how to initially configure your own language pack.
What is a Language Pack?
A language pack is a collection of translated language files and code, to handle dynamic content, that can be installed and activated to display the system in a different locale.
All language packs belong within the /addons/Languages
directory, each with its own directory that is named after the language. Each language pack usually has the following basic file structure:
File/Folder | Description |
---|---|
config.php |
The configuration file for the language pack, where you set the name, version and other important details about the language pack that shows in the operator panel when activating the language for the first time. |
Controllers/ |
Controllers are where the logic of your language pack is stored, namely if you need to seed any dynamic content to the database. |
Lang/ |
The translated language files are found in this folder. |
Overriding Translations
If you are looking to just update lines from an existing language pack such as English, you can do this through a plugin instead.
Starting with the Make Command
We recommend using the included make:language
command to generate the initial codebase for your own
language pack. The command can be run on the CLI (in the base SupportPal directory) by entering
php artisan make:language <locale>
with your locale code.
The command will automatically create the language pack in the filesystem and activate it. You will now be able to see it on the Languages page (Settings -> General -> Languages) in the operator panel.
Configuration Options
The config.php
file is automatically generated under your language pack folder. There are a few more configuration options available that you may wish to edit:
Setting | Description |
---|---|
Name | Set the user-friendly name for the language pack. For example, "Greek". |
Code | The locale code, conforming to the ISO requirements described above. Use the make command to ensure a valid locale code is selected. |
Text Direction | The direction in which text is written in this language. Accepted values are ltr (left-to-right) and rtl (right-to-left), defaults to ltr if not set. |
Language Pack URI | If you are developing this language pack to be distributed to other users, you may include a specific link about the language pack from your website. This is particularly useful if you will have a specific page and/or documentation on your website. |
Version | Set the version of the language pack, such as '1.2.0'. |
Icon | Set an icon to be displayed in the languages list. It must be a full file path, we recommend to use __DIR__ to avoid hard coding the directory name. If no icon is set, it will generate an icon based on the first letter in the language name. |