承接 mmoreram/translation-server 相关项目开发

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

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

mmoreram/translation-server

Composer 安装命令:

composer require mmoreram/translation-server

包简介

PHP translation server

README 文档

README

This Translation Server aims to provide a very easy, intuitive and fast way of adding new translations in your projects, following the Symfony Standards, and using the console as interface.

Tags

  • Use last unstable version ( alias of dev-master ) to stay in last commit
  • Use last stable version tag to stay in a stable release.
  • Latest Unstable Version Latest Stable Version

Install

Install Translation Server in this way:

$ composer global require mmoreram/translation-server=dev-master

If it is the first time you globally install a dependency then make sure you include ~/.composer/vendor/bin in $PATH as shown here.

Always keep your Translation Server installation up to date:

$ composer global update mmoreram/translation-server

.phar file

You can also use already last built .phar.

$ git clone git@github.com:mmoreram/translation-server.git
$ cd translation-server
$ php build/translation-server.phar

You can copy the .phar file as a global script

$ cp build/translation-server.phar /usr/local/bin/translation-server

Compile

Finally you can also compile your own version of the package. ( You need set phar.readonly = Off in your php.ini ).

$ git clone git@github.com:mmoreram/translation-server.git
$ cd translation-server
$ composer update
$ php bin/compile
$ sudo chmod +x build/translation-server.phar
$ build/translation-server.phar

You can copy the .phar file as a global script

$ cp build/translation-server.phar /usr/local/bin/translation-server

Config

If your project wants to provide support for this project, make sure you place the definition about where are your translations, your master language and what languages do you support in a file called .translation.yml.

This file has this format (no needs to explain it, right? ^^)

master_language: en
languages:
    - en
    - es
    - ca
    - fr
    - de
    - it
    - fi
    - eu
    - gl
    - eo
    - nl
paths:
    - src/Folder/*/Resources/translations

you can also define where to search the .translation.yml file using the --config|-c option

$ translation-server translation:server:view --config="src/"

Commands

This server provides a set of commands useful for your project. Let's see all these commands one by one.

Console Tool

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.

Available commands:
  help                   Displays help for a command
  list                   Lists commands
translation
  translation:server:add   Add new translation
  translation:server:sort  Sort translations
  translation:server:view  View statics about the server

Translations statics

You can see all your translation statics by using this command. Without any extra configuration, you will be able to see statics of all the project.

$ translation-server translation:server:view

[Trans Server] Command started at Thu, 08 Oct 2015 00:52:41 +0200
[Trans Server] Translations for [en] is 100% completed. 0 missing
[Trans Server] Translations for [ca] is 99.57% completed. 4 missing
[Trans Server] Translations for [es] is 99.57% completed. 4 missing
[Trans Server] Translations for [fr] is 78.34% completed. 203 missing
[Trans Server] Translations for [de] is 68.84% completed. 292 missing
[Trans Server] Translations for [it] is 0.11% completed. 936 missing
[Trans Server] Translations for [nl] is 0% completed. 937 missing
[Trans Server] Translations for [eo] is 0% completed. 937 missing
[Trans Server] Translations for [gl] is 0% completed. 937 missing
[Trans Server] Translations for [eu] is 0% completed. 937 missing
[Trans Server] Translations for [fi] is 0% completed. 937 missing
[Trans Server] Command finished in 932 milliseconds
[Trans Server] Max memory used: 13893632 bytes

Filtering by language

You can filter all results by language using the option [--language|-l] in all your commands. This is just a mask, so if you define one or more language, will simply mask all results provided to you.

$ translation-server translation:server:view --language es -l ca

[Trans Server] Command started at Thu, 08 Oct 2015 00:54:09 +0200
[Trans Server] Translations for [en] is 100% completed. 0 missing
[Trans Server] Translations for [ca] is 99.57% completed. 4 missing
[Trans Server] Translations for [es] is 99.57% completed. 4 missing
[Trans Server] Command finished in 917 milliseconds
[Trans Server] Max memory used: 13893632 bytes

As you can see, you can provide several languages

Filtering by domain

You can filter all results by domain using the option [--domain|-d] in all your commands. This is just a mask, so if you define one or more domains, will simply mask all results provided to you.

$ translation-server translation:server:view --domain routes

[Trans Server] Command started at Thu, 08 Oct 2015 00:56:16 +0200
[Trans Server] Translations for [de] is 100% completed. 0 missing
[Trans Server] Translations for [en] is 100% completed. 0 missing
[Trans Server] Translations for [ca] is 100% completed. 0 missing
[Trans Server] Translations for [es] is 100% completed. 0 missing
[Trans Server] Translations for [eo] is 0% completed. 38 missing
[Trans Server] Translations for [nl] is 0% completed. 38 missing
[Trans Server] Translations for [gl] is 0% completed. 38 missing
[Trans Server] Translations for [it] is 0% completed. 38 missing
[Trans Server] Translations for [fr] is 0% completed. 38 missing
[Trans Server] Translations for [fi] is 0% completed. 38 missing
[Trans Server] Translations for [eu] is 0% completed. 38 missing
[Trans Server] Command finished in 842 milliseconds
[Trans Server] Max memory used: 13369344 bytes

You can provide as well several domains, even mix languages and domains.

Asking for new translations

The power of this tool is that, just telling what language you'd like to work with, the tool will ask you interactively some translations.

Let's see an example. In that case we will ask some translations in Basque, but we only want to add routing translations, marked with the domain routes.

$ translation-server translation:server:add --language eu --domain routes

[Trans Server] Command started at Thu, 08 Oct 2015 00:59:43 +0200
[Trans Server] Language : eu
[Trans Server] Key : store_cart_nav
[Trans Server] Original : /cart/nav
[Trans Server] Translation : []

At this point, the prompt will wait for your response here. As soon as you have introduced your translation, just press Enter and your translation will be stored in it's place.

This means that if a new file must be created in order to store your translation, for example if you are creating a new language, the process will create it.

$ translation-server translation:server:add --language eu --domain routes

[Trans Server] Command started at Thu, 08 Oct 2015 00:59:43 +0200
[Trans Server] Language : eu
[Trans Server] Key : store_cart_nav
[Trans Server] Original : /cart/nav
[Trans Server] Translation : /saskia/nab

[Trans Server] Command started at Thu, 08 Oct 2015 01:00:25 +0200
[Trans Server] Language : eu
[Trans Server] Key : store_checkout_address
[Trans Server] Original : /cart/address
[Trans Server] Translation : []

As soon as the value is saved, the system will ask for another translation. As long as you don't press Ctrl+C, the system will do it once and again.

Guessing missing translations

For lazy people, you can even translate your site using Google Translate. Of course we strongly recommend you to use this feature carefully, with a post checking of the results.

$ translation-server translation:server:guess --language eu

[Trans Server] Command started at Thu, 08 Oct 2015 00:59:43 +0200
[Trans Server] Language : eu
[Trans Server] Key : store_cart_nav
[Trans Server] Original : /cart/nav
[Trans Server] Translation : /saskia/nab

The command will start guessing your missing translations until you decide to stop with Ctrl+C.

This project uses the library Stichoza/google-translate-php. Easy and simple. Big kudos!

Of course, you can filter by language and domain.

Sorting your translations

You can sort all your translations as well, just using this great command.

$ translation-server translation:server:sort

[Trans Server] Command started at Thu, 08 Oct 2015 01:06:15 +0200
[Trans Server] Your translations have been sorted successfuly
[Trans Server] Command finished in 1288 milliseconds
[Trans Server] Max memory used: 13631488 bytes

Again, you can filter by language and domain.

mmoreram/translation-server 适用场景与选型建议

mmoreram/translation-server 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.82k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2015 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「translation」 「server」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 mmoreram/translation-server 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 15
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

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