aiken/i18next 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aiken/i18next

Composer 安装命令:

composer require aiken/i18next

包简介

PHP class for basic i18next functionality

README 文档

README

PHP class for basic i18next functionality.

Features

Usage

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

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

Methods

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

Loads translation files from given path. Looks for translation.json by default.

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

You can also use variables and split namespaces and languages to different files.

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

Method throws an exception if no files are found or the json can not be parsed.

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

Returns translated string by key.

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

boolean i18next::existTranslation( string $key );

Checks if translated string exists.

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

Changes language.

array i18next::getMissingTranslations();

Gets an array of missing translations.

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

Multilines in JSON-arrays

You can have html content written with multilines in JSON File

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

统计信息

  • 总下载量: 35.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 4
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: Beerware
  • 更新时间: 2017-06-24