Language Packs - parpalak/s2 GitHub Wiki
S2 language packs contain nearly all the strings displayed in the browser (e.g., button labels, error messages). They also define localization parameters, such as date and time formats, decimal separators, etc.
Language packs are located in the _lang/
folder and consist of directories
with several PHP files containing string arrays.
A language pack can be changed in the control panel. Usually, the language pack is chosen and adjusted (if needed) during the initial installation and setup of the engine for a particular site.
Let’s examine a fragment of the file _lang/English/common.php
:
<?php
return [
'locale' => 'en',
// ...
// Page content
'In this section' => 'In this section',
'Read in this section' => 'Read in this section',
'More in this section' => 'More in the section <nobr>“%s”</nobr>',
'Subsections' => 'Subsections',
'Tags' => 'Tags',
'With this tag' => 'On the subject “%s”',
'Read next' => 'Read next',
'Comments' => 'Comments',
'Copyright 1' => '© %2$s %1$s.',
'Copyright 2' => '© %2$s–%3$s %1$s.',
'Powered by' => 'Powered by %s CMS.',
'Last comments' => 'Last comments on the site',
'Last discussions' => 'Last discussions on the site',
'Here' => '← here',
'There' => 'there →',
'Favorite' => 'Favorite',
// ...
To create a new language pack, the easiest way is to copy and rename an existing pack,
then edit the array values (the strings between apostrophes after the =>
symbols)
in a text editor.
Files must be saved exclusively in UTF-8 encoding without BOM (byte order mark).
As the name suggests, language packs are primarily intended for changing the interface language.
They can also be used to customize the engine for a specific website.
For example, if you want to replace “sections” with “categories”, you would change the strings
'In this section'
to 'In this category'
, 'Read in this section'
to 'Read in this category'
,
and so on.
It is recommended to edit a renamed copy of the language pack
to avoid accidentally losing changes during engine updates.