abbadon1334/atk4-i18next-php 问题修复 & 功能扩展

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

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

abbadon1334/atk4-i18next-php

Composer 安装命令:

composer require abbadon1334/atk4-i18next-php

包简介

description

README 文档

README

Based on i18next http://i18next.com

Interpolate direct with ATK4 - Agile Toolkit Models https://www.agiletoolkit.org/

Build Status Codacy Badge Codacy Badge Coverage Status StyleCI Maintainability Test Coverage

install with composer :

composer require abbadon1334/atk4-i18next-php

All documentation about the original library can be found here : http://i18next.com/

How to use :

$this->translator = new Translator();
$this->translator->setTranslationsPath(__DIR__.'/data/locales');

Define if filename will be used has namespace :

$this->translator->useFilenameAsNamespace(true);

Define primary and fallback languages (using names of the folder) :

$this->translator->setLanguagePrimary($language);
$this->translator->setLanguageFallback($fallback);

Add additional language :

$this->translator->addLanguage('it');

Translate :

interface TranslatorInterface
{
    /**
     * Translates the given message.
     *
     * @param string      $key
     * @param array|null  $parameters Array of parameters used to translate message
     * @param string|null $context
     * @param string|null $locale     The locale or null to use the default
     *
     * @return string The translated string
     */
    public function _(string $key, ?array $parameters = null, ?string $context = null, ?string $locale = null): string;
}

// Usage

$result = $this->translator->_('definitionKey');

$result = $this->translator->_('definitionKey', ['param1' => 'test']);

$result = $this->translator->_('definitionKey', ['param1' => 'test'], 'context');

$result = $this->translator->_('definitionKey', ['param1' => 'test'], 'context', 'specificLanguage');

$result = $this->translator->_('namespace:definitionKey', ['param1' => 'test'], 'context', 'specificLanguage');

Support I18Next

http://i18next.com
  • Read translations files from folder, every folder is a language code
    • JSON
    • YAML
    • PHP Array
  • Write translations files to a folder, every folder is a language code
    • JSON
    • YAML
    • PHP Array
  • Get a defined translation in primary language
    • If not found try in fallback language
      • If not found return original string
  • Namespaces
    • Get defined translation based on prioritized fallback namespaces
  • Context as {key}_{context}
  • Plurals
    • Singular as {key}
    • Plurals as {key}_plural
    • Multiple plurals as {key}_{int $counter}
      • Manage when $counter is bigger than max defined plurals
    • Nested interpolate plurals
    • Intervals
  • Interpolate
    • Replace {{key}} with defined $paramater value
      • If {{key}} has a point like {{key.index}} and $parameters[index] is an array or object will retrive the value
  • Nesting
    • Basic
    • Plurals
  • Formatting
  • Adding Helper for use method Translator::_ as global functions __
  • Adding Helper for use Translator as a global singleton instance
  • Collect missing requested keys
  • Adding Helper for search/collect calls to method Translator _ in code
  • Added direct translations using key as translation

Support ATK4 - Agile Toolkit Model

https://www.agiletoolkit.org
  • Interpolate with \atk4\data\Model

abbadon1334/atk4-i18next-php 适用场景与选型建议

abbadon1334/atk4-i18next-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 abbadon1334/atk4-i18next-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 abbadon1334/atk4-i18next-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 abbadon1334/atk4-i18next-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 47
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-10