2017 © Pedro Peláez
 

library i18next-php

PHP class for basic i18next functionality.

image

kopfwelt/i18next-php

PHP class for basic i18next functionality.

  • Saturday, December 5, 2015
  • by kopfwelt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 343 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 1 Versions
  • 90 % Grown

The README.md

i18next-php

PHP class for basic i18next functionality., (*1)

Features

Usage

// init i18next instance
i18next::init('en');

// get translation by key
echo i18next::getTranslation('common.dog');

Methods

i18next::init( string $languageKey [, string $path ] );

Loads translation files from given path. Looks for translation.json by default., (*2)

i18next::init('en', 'my/path/');
// loads my/path/translation.json

You can also use variables and split namespaces and languages to different files., (*3)

i18next::init('en', 'languages/__lng__/__ns__.json');
// loads languages/en/common.json, languages/fi/common.json, etc...

Method throws an exception if no files are found or the json can not be parsed., (*4)

mixed i18next::getTranslation( string $key [, array $variables ] );

Returns translated string by key., (*5)

i18next::getTranslation('common.cat', array('count' => 2, 'lng' => 'fi'));

boolean i18next::existTranslation( string $key );

Checks if translated string exists., (*6)

void i18next::setLanguage( string $language [, string $fallback ] );

Changes language., (*7)

array i18next::getMissingTranslations();

Gets an array of missing translations., (*8)

array(1) {
    [0]=> array(2) {
        ["language"]=> string(2) "en"
        ["key"]=> string(14) "common.unknown"
    }
}

Multilines in JSON-arrays

You can have html content written with multilines in JSON File, (*9)

{
    "en": {
        "common": {
            "thedoglovers":["The Dog Lovers by Spike Milligan",
"So they bought you",
"And kept you in a",
"Very good home"]
        }
    }
}

The Versions

05/12 2015

dev-master

9999999-dev https://github.com/kopfwelt/i18next-php

PHP class for basic i18next functionality.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Mika Simanainen
by Steve Sinnwell