承接 conquer/i18n 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

conquer/i18n

最新稳定版本:1.0.1

Composer 安装命令:

composer require conquer/i18n

包简介

The I18n automatic translation extension for the Yii2 framework

README 文档

README

Description

This extension makes it possible to automatically translate messages using external services.

##Google With Google Translate, you can dynamically translate text between thousands of language pairs. The Google Translate API lets websites and programs integrate with Google Translate programmatically. Google Translate API is available as a paid service. See the Pricing and FAQ pages for details.

##Yandex The API provides access to the Yandex online machine translation service. It supports more than 40 languages and can translate separate words or complete texts. The API makes it possible to embed Yandex.Translate in a mobile app or web service for end users. Or translate large quantities of text, such as technical documentation.

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require conquer/i18n "*"

or add

"conquer/i18n": "*"

to the require section of your composer.json file.

To create database tables run migration command

$ yii migrate --migrationPath=@conquer/i18n/migrations

Usage

You need to configure Module and i18n component

$config = [
    'bootstrap' => ['translate'],
    'language' => 'ru',
    'modules' => [
        'translate' => 'conquer\i18n\Module'
    ],
    'components' => [
        'i18n' => [
            'class' => 'yii\i18n\I18N',
            'translations' => [
                '*' => [
                    'class' => 'conquer\i18n\MessageSource',
                    'translator' => [
                     //   'class'=>'conquer\i18n\translators\GoogleTranslator',
                     //   'apiKey' => 'obtain API key in the google developer console',
                        'class'=>'conquer\i18n\translators\YandexTranslator',
                        'apiKey' => '[yandex form](https://tech.yandex.com/keys/get/?service=trnsl)',
                    ],
                ],
            ],
        ],
    ],
];

Use \Yii::t function to translate messages

<h1><?= \Yii::t('app', 'Congratulations!') ?></h1>

"*" Translation category is used by default for all non-translated messages.

You can configure a separate category for the translation of messages by external translator.

    'components' => [
        'i18n' => [
            'class' => 'yii\i18n\I18N',
            'translations' => [
                'yandex' => [
                    'class' => 'conquer\i18n\MessageSource',
                    'translator' => [
                        'class'=>'conquer\i18n\translators\YandexTranslator',
                        'apiKey' => '[yandex form](https://tech.yandex.com/keys/get/?service=trnsl)',
                    ],
                ],
            ],
        ],
    ],

Use \Yii::t function to translate messages in "yandex" category

<h1><?= \Yii::t('yandex', 'Congratulations!') ?></h1>

License

conquer/i18n is released under the MIT License. See the bundled LICENSE.md for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固