https://github.com/mberatsanli/multilangphp
PHP multi language
https://github.com/mberatsanli/multilangphp
languages multilang multilanguage php php-library
Last synced: about 2 months ago
JSON representation
PHP multi language
- Host: GitHub
- URL: https://github.com/mberatsanli/multilangphp
- Owner: mberatsanli
- Created: 2019-04-19T12:32:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-20T19:47:34.000Z (over 6 years ago)
- Last Synced: 2025-01-02T14:17:06.840Z (over 1 year ago)
- Topics: languages, multilang, multilanguage, php, php-library
- Language: PHP
- Homepage: https://mberatsanli.github.io/multilangPHP/
- Size: 45.9 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# multilangPHP v2.0.1
[](http://mberatsanli.github.io/multilangPHP)
[](http://mberatsanli.github.io/multilangPHP)
[](http://mberatsanli.github.io/multilangPHP)
[](http://mberatsanli.github.io/multilangPHP)
[](http://mberatsanli.github.io/multilangPHP)
[](https://travis-ci.org/mberatsanli/multilangPHP/jobs/522465502)
[](hhttps://scrutinizer-ci.com/g/mberatsanli/multilangPHP/)
[](https://scrutinizer-ci.com/g/mberatsanli/multilangPHP/)
### Import the library
```php
require_once("lib/multilang.php");
```
## Using
#### > How to starting
```php
multilang::setup();
```
#### > Set Languages Directory
```php
multilang::set("dir", "../demo/langs/");
```
before `mutlilang::setup();`
#### > GET function
```php
multilang::get($req, $return);
```
| $return | what is does |
|--|--|
| 1 | return |
| 0 | echo |
| $request | what is does | output example |
|--|--|--|
| lang | Gives you the language selected by the user | en |
| dir | Gives you the directory | ../demo/langs/ |
| log | Gives the log of the library | array() |
| log_last | Gives the last log the library | The current language is set tr |
| dir&lang | Gives the language file directory selected by the user | ../demo/langs/tr.php |
#### > List the language in the defined direcory
```php
echo multilang::listlang($returnType);
```
| $returnType | what is does | output |
|-------------|--------------|--------|
| html | Gives languages in html format | div.multilang > [a href="?lang=tr" title="language tr"]tr[/a] |
| array | Gives languages in array | array('tr' => 'tr.php') |
#### > How to create the language file
For example, the folder with the language files: `../demo/langs/` and we create a language folder in the directory. Create `LANGUAGE.php` for example `az.php`
```php
// '../demo/langs/az.php'
$LANG = array(); // We are creating an array called LANG
$LANG['test'] = "Bu bir testdir.";
$LANG['CALLED_NAME'] = "CONTENTS";
```
#### > How to get the text
```php
echo multilang::lang($type);
```
$type is a CALLED NAME
```php
// Example
echo multilang::lang('test'); // Output (return): Bu bir testtir.
```
## Example Using
```php
// index.php
require_once("lib/multilang.php");
multilang::set("dir", "langs/"); // We defined the language directory
multilang::setup(); // We starting the library
echo multilang::lang("test"); // Echo the text
print_r(multilang::get("log", 1)); // Print the log array
```