2017 © Pedro Peláez
 

library language

Language management

image

izis/language

Language management

  • Friday, October 27, 2017
  • by iZis
  • Repository
  • 1 Watchers
  • 0 Stars
  • 161 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Language

Language is a proxy I use to symfony/translation component is a modular PHP package designed for managing and translating multilingual content in your web projects. This project simplifies the use of language files and provides a clear API for easily handling translations., (*1)

Features

  • Built on the symfony/translation component for robust translation capabilities.
  • Uses the symfony/string inflector for pluralize and singularize.
  • Load default or application-specific language files.
  • Flexible management of translation keys.
  • Support for YAML format language files.
  • Easy integration with other frameworks or custom solutions.
  • Optimized for fast performance and maximum extensibility.
  • Inflector for French, English & soon Spanish -> introduced in symfony/string 7.2 (PHP >= 8.2).

Installation

Add the package to your project using Composer:, (*2)

composer require jdz/language

Usage

For a complete example, check the example folder in the repository., (*3)

Initialization

use JDZ\Language\Language;

$language = new Language(
    // app languages
    ['fr', 'en'],
    // default language
    'fr'
);

### load user language
if not an available languages it falls back to the default language

```php
$language->load('fr');

load translations from array

$language->loadArray([
    'welcome_message' => 'Hi !',
    'test' => [
        'key1' => 'Test 1 nested',
        'key2' => 'Test 1 nested 2',
    ],
    'test2' => 'Test 2',
]);

load translations from YAML file

$language->loadYmlFiles([
    __DIR__ . '/file1.yml',
    __DIR__ . '/file2.yml',
]);
$language->loadYmlFile(__DIR__ . '/file3.yml');
welcome_message: "Welcome"
goodbye_message: "Goodbye"

Setting Values

$language->set('custom.key', 'My custom value');

Getting Values

$welcomeMessage = $language->get('welcome_message');
// Hi !
$customMessage = $language->get('custom.key');
// My custom value
$notDefined = $language->get('test.me');
// null
$notDefinedButDefault = $language->get('test.me', 'Default value');
// Default value

Methods

Method Description
load() Load a user language.
loadYamlFiles() Load translations from an array of YAML files.
loadYamlFile() Load translations from a YAML file.
loadArray() Load translations from an array of key => value pairs.
set() Adds a translation.
get() Retrieves a translation at the specified path.
has() Checks if a translation exists at the specified path.
plural() Load a plural.
pluralize() Uses the symfony/string inflector.
pluralize() Uses the symfony/string inflector.

License

This project is licensed under the MIT License. See the LICENSE file for details., (*4)

Author

(c) Joffrey Demetz joffrey.demetz@gmail.com, (*5)

The Versions

27/10 2017

dev-master

9999999-dev http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

09/10 2017

2.0.1

2.0.1.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

13/09 2017

2.0.0

2.0.0.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

16/04 2017

1.2.1

1.2.1.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

24/03 2017

1.2.0

1.2.0.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

20/03 2017

1.1.0

1.1.0.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

10/03 2017

1.0.1

1.0.1.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n

08/03 2017

1.0.0

1.0.0.0 http://joffreydemetz.com/izis/language/

Language management

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

language i18n