1. Go to this page and download the library: Download crosa7/leaf-omniglot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
crosa7 / leaf-omniglot example snippets
// Create a folder named "locales" in your project root
// (you can also create in another place that makes more sense, just be aware to configure the path accordingly)
// Create the following file inside the "locales" folder
en_US.locale.json
// With the following content
{
"welcome.title": "Hello World"
}
DEFAULT_LOCALE => en_US
// Translation file name
en_US.locale.json
// Your class: RequestLocaleStrategy
CUSTOM_LOCALE_STRATEGY_CLASS_NAME => RequestLocaleStrategy::class
// Translation file content
{
"welcome.page.title": "Welcome %firstName% --lastName-- to the dashboard",
"navbar.title": "Dashboard"
}
// Translation method call
tl('welcome.page.title', ['%firstName%' => 'John', '--lastName--' => 'Doe']); // Welcome John Doe to the dashboard
// You can use anything as parameter identifier. Omniglot will look for anything that you pass as key
// in the parameters array and replace anything that it finds with this pattern and replace by the value you pass.
// In case of translations without parameters you can simply call:
tl('navbar.title'); // Dashboard
{
"locale": "en_US"
}
en_US.locale.json
pt_PT.locale.json
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.