Skip to content

paquettg/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18n

Version 1.0.1

Build Status Coverage Status

I18n is a php framework agnostic package to handle I18n functionality (such an original name). The goal is to have the ability to implement multiple languages into a website with out needing to depend on a framework.

Install

This package can be found on packagist and is best loaded using composer. We support PHP 7.1, 7.2, and 7.3.

Simple Example

You can find many examples of how to use the package and any of its parts (which you will most likely never touch) in the tests directory. The tests are done using PHPUnit and are very small, a few lines each, and are a great place to start. Given that, I'll still be showing examples of how the package is intended to work. The following example is a very simplistic usage of the package, good place to start.

use I18n\I18n;

$i18n = new I18n;
$i18n->set([
	'foo' => 'bar',
	'baz' => [
		'rawr' => 'meow?',
	],
], 'en_CA');
$i18n->load('en_CA');

echo $i18n->get('baz.rawr'); // will output 'meow?'

You may also set a directory to look at to load the given locales.

use I18n\I18n;

$i18n = new I18n;
$i18n->load($pathToLocaleDirectory);
$i18n->load($locale);

Using static facade

We also support a static facade so you don't need to carry around the I18n object to every part of your application.

use I18n\Facade\StaticI18n;

StaticI18n::mount();
I18n::set([
	'foo' => 'bar',
	'baz' => [
		'rawr' => 'meow?',
	],
], 'en_CA');
I18n::load('en_CA');
echo I18n::get('baz.rawr');

About

php i18n stand alone package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages