2017 © Pedro Peláez
 

library i18n

Internationalization package of the CodeCollab project

image

codecollab/i18n

Internationalization package of the CodeCollab project

  • Saturday, July 16, 2016
  • by PeeHaa
  • Repository
  • 1 Watchers
  • 0 Stars
  • 54 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 26 % Grown

The README.md

I18n

Internationalization package of the CodeCollab project, (*1)

Build Status MIT License Latest Stable Version Total Downloads Latest Unstable Version, (*2)

Requirements

PHP7+, (*3)

Installation

Include the library in your project using composer:, (*4)

{
    "require-dev": {
        "codecollab/i18n": "^1"
    }
}

Usage

This library uses simple php files containing an array of translations based on key/value pairs. The array should be named $texts., (*5)

The filename of the translations should be based on the language it targets, e.g. en_US.php. An simple example of translations in a file:, (*6)

<?php

$texts = [
    'translation.title'        => 'Translation',
    'translation.description'  => 'This is an example translation.',
    'translation.variable.%'   => 'Copyright %d Some Company',
];

To use translations in your application first create an instance of the translation class by passing the directory in which the translation files are and the language to translate to:, (*7)

<?php

$translator = new \CodeCollab\I18n\FileTranslator('/path/to/translations', 'en_US');

echo $translator->translate('translation.title'); // Translation
echo $translator->translate('translation.variable.%', [2015]); // Copyright 2015 Some Company

Exceptions

When a translation file could not be found a \CodeCollab\I18n\UnsupportedLanguageException will be thrown., (*8)

When loading a translation file it will be checked to ensure it has the correct format. if the file is not a valid translation file a \CodeCollab\I18n\InvalidFileException will be thrown., (*9)

Interface

When using translators in your application always hint against the \CodeCollab\I18n\Translator interface instead of the concrete implementation. This allows you to use different translation implementations later without having to change you classes., (*10)

Contributing

How to contribute, (*11)

License

MIT, (*12)

Security issues

If you found a security issue please contact directly by mail instead of using the issue tracker at codecollab-security@pieterhordijk.com, (*13)

The Versions

16/07 2016

dev-master

9999999-dev https://github.com/CodeCollab/I18n

Internationalization package of the CodeCollab project

  Sources   Download

See the LICENSE file

The Requires

  • php ^7

 

The Development Requires

i18n internationalization codecollab

16/07 2016

1.0.1

1.0.1.0 https://github.com/CodeCollab/I18n

Internationalization package of the CodeCollab project

  Sources   Download

See the LICENSE file

The Requires

  • php ^7

 

The Development Requires

i18n internationalization codecollab

09/12 2015

1.0.0

1.0.0.0 https://github.com/CodeCollab/I18n

Internationalization package of the CodeCollab project

  Sources   Download

See the LICENSE file

The Requires

  • php 7.0.*

 

The Development Requires

i18n internationalization codecollab