-
Notifications
You must be signed in to change notification settings - Fork 0
General Usage
Nikolai Plath edited this page Jul 17, 2018
·
4 revisions
At a very minimal do the following:
- Create a composer project
- Add the library
- Create a
/test.php
file at the root of your repository (for demo purpose) - Create the directories
/someDir/someExtension/g11n/de-DE
- Create a language file
de-DE.someExtension.po
(see screen shot) - Create a
/cache
directory
#!/usr/bin/env php
<?php
use ElKuKu\G11n\G11n;
use ElKuKu\G11n\Support\ExtensionHelper;
include 'vendor/autoload.php';
// Set the language cache directory
ExtensionHelper::setCacheDir('cache');
// Set the language path(s)
ExtensionHelper::addDomainPath('someName', 'someDir');
// Set the current language
G11n::setCurrent('de-DE');
// Do a check here if you are in dev mode
if (true /* dev mode */)
{
ExtensionHelper::cleanCache();
}
// Load the language file(s)
G11n::loadLanguage('someExtension', 'someName');
echo g11n3t('Hello test');
msgid ""
msgstr ""
"Language: de-DE\n"
msgid "Hello test"
msgstr "Hallo Test"
Run the script.
$ ./test.php
Hallo Test
The output should be: Hallo Test
Note that language files will be parsed and cached, so you have to run the command
ExtensionHelper::cleanCache();
To see the changes.
Read about some more advanced Usage.