I am customizing moodle in a new project. I want to add my limited strings to my special language file, in order to call it in any place. So I need to add a new file to language packs, e.g. bahar.php
For a local plugin the folder is
/local/yourpluginname/lang/en/local_yourpluginname.php
Then the file should contain
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'Your plugin name';
$string['mycustomstring'] = 'A custom string';
Then get the string using
echo get_string('mycustomstring', 'local_yourpluginname');
By default you will need to have an en
folder with English strings.
But then you can also add additional languages using the iso code. For example to add Persian/Farsi the code is fa
. So create an additional folder:
/local/yourpluginname/lang/fa/local_yourpluginname.php
Then in the file add:
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'نام افزونه شما';
$string['mycustomstring'] = 'رشته های سفارشی';
You will also need to install the Farsi language pack. Go to site admin -> language packs or simply go direct to yourmoodlesite.com/admin/tool/langimport/index.php
and select Farsi.
If you want to translate the existing Moodle strings, then it might be better to translate them via AMOS. Then everyone will benefit from the translations. https://docs.moodle.org/dev/Contributing_a_translation