Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I18N Package

Packagist PHP Version Support Packagist Version Packagist Downloads Composer dependencies Test workflow Codecov composer.lock

I18N.

Installation

composer require rancoud/i18n

How to use it?

You need a file LANG.php where LANG is the filename.
It will contains an array key values:

return [
    'Hello' => 'Bonjour'
];

You have to set the default directory and language

$defaultDirectory = '/path/to/translations/';
$defaultLanguage = 'en';
I18N::setDefaults($directory, $defaultLanguage);

In action:

I18N::echo('Hello');
// it will produce in output 'Hello'

I18N::echo('another string');
// it will produce in output 'another string' because the key doesn't exist in the file

$string = I18N::get('Hello');
// it will return 'Hello'

// you can use different language file instead of the default one
$string = I18N::get('string in other lang', 'es');
// it will return the translation of 'string in other lang' present in the es.php file

I18N Methods

General static Commands

  • setDefaults(directory: string, language: string):void
  • echo(key: string, [language: string = null]):void
  • get(key: string, [language: string = null]):string

How to Dev

composer ci for php-cs-fixer and phpunit and coverage
composer lint for php-cs-fixer
composer test for phpunit and coverage

About

Internationalization Package

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages