Download the PHP package initphp/translator without Composer
On this page you can find all versions of the php package initphp/translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download initphp/translator
More information about initphp/translator
Files in initphp/translator
Package translator
Short Description This library; It is a micro library that will allow you to add multi-language support to your projects or libraries.
License MIT
Informations about the package translator
InitPHP Translator
This library; It is a micro library that will allow you to add multi-language support to your projects or libraries.
Requirements
- PHP 7.4 or higher
Installation
Usage
What does a language file look like?
File? Directory?
You can use a single file for each language or multiple files under a directory.
Use File
If you are going to use a single file for a language; Your directory structure will look something like this;
Your code looks like the following;
Use Directory
If you want to use directories that contain multiple files for each language, your directory structure will be something like this;
Your code looks like the following;
Methods
setDir()
Defines the full path to the parent directory where the language files are kept.
Structure :
setDefault()
Defines the main translation language to be used by default if the desired translation in the current language is not found.
Structure :
Note : If a text is given by default during use; this library uses the default string you provided at the time of use.
useFile()
and useDirectory()
These two methods; tells you whether to use a single php file or a directory for localization. See "File? Directory?" above for more.
Note : If not specified, the file system is used by default.
Structures :
change()
Changes the current language and loads the desired language if it is not already installed.
Structure :
_r()
Returns the desired translation value.
Structure :
$key
: The key to the desired translation.$default
: The string to substitute if the requested translation is not found.$context
: An associative array that reports the value of placeholders, if any, in the translation.
_e()
Outputs the desired value directly.
$lang->_e('hello')
=echo $lang->_r('hello')
Structure :
Getting Help
If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.
Contributing
All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.
- Fork it ( https://github.com/initphp/translator/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am "Add some feature"
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Credits
License
Copyright © 2022 MIT License