Download the PHP package tleckie/translate without Composer
On this page you can find all versions of the php package tleckie/translate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tleckie/translate
More information about tleckie/translate
Files in tleckie/translate
Package translate
Short Description PHP translator
License MIT
Homepage https://github.com/teodoroleckie/translate
Informations about the package translate
Fast, powerful, scalable and customizable php translator library
You can install the package via composer:
Usage
Create an instance of the Translator class to which you will assign a loader. The loader must have the directory in which the translation files are stored, it must also indicate the extension of the translation files.
Your translations file should look like this:
The name of the file that stores the translation should look like this:
The trans() method takes multiple arguments. The first is the key of the translation array, it is the value that will be searched for in its corresponding file.
The second argument (optional) is an array of values to be replaced in the translated value. If you want to add values to your translated text you must indicate it with "%s". Note that the number of arguments must match the number of "%s".
Your translations file should look like this:
Even if you configure your translator to load a specific language, you can also change the language at any time if you need.
You can create your translation files by specifying the language and country defined by the provided locale. You can also decide whether to use the same language for different countries. Regional configuration example: "en_US" and "en_GB" In this case, you just need to create a file that has the following name:
In that case the following calls will have the same result and will load the translations from the same file.
You can also implement your own loader to connect to your preferred data source. You simply have to implement the LoaderInterface interface.
That's all! I hope this helps you ;)