Download the PHP package comfyphp/lang without Composer
On this page you can find all versions of the php package comfyphp/lang. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download comfyphp/lang
More information about comfyphp/lang
Files in comfyphp/lang
Package lang
Short Description Multiple languages extension for ComfyPHP
License MIT
Homepage https://github.com/comfyphp/lang
Informations about the package lang
ComfyPHP Multiple Languages Extension
This is an extension for ComfyPHP framework to enable the function using multiple languages.
Default & Recommended Directory Structure
Before Using it
As this is an extension for ComfyPHP, All dependencies required in ComfyPHP and ComfyPHP itself is needed to use this extension.
Download / Install
To use this extension, you can install it with Composer.
Usage
Initialize
ComfyPHP will search for all the languages base on the CONFIG_LANG_PATH
settings in comfy.lang.config.php
.
You can add the following line into somewhere and import it into every files later, here we take src/pages/_init.php
for example:
Create JSON
Create separate JSON files for each language you want to support. And Place these files into the languages folder. For example, create the following files:
src/langs/en/index.json
:
src/langs/en/special.json
:
Usage
In the files where you want to use the multiple languages extension, add the following code to require the file which you initialized the lang extension and enable the function to use those languages:
You can now use language strings in your code. When you write $l("hello")
, the extension will look for the key hello
in the index.json
file. If you write $l("special:setting.info")
, the extension will search for the key info
under the setting
key in the special.json
file.
Reserved Variables of the Extension
License
This project is MIT licensed, you can find the license file here.