PHPackages                             rw/translation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. rw/translation

Abandoned → [revenuewire/translation](/?search=revenuewire%2Ftranslation)Library[Localization &amp; i18n](/categories/localization)

rw/translation
==============

RW Translation Service

5.0.0(1y ago)191Apache-2.0PHP

Since Apr 7Pushed 1y ago7 watchersCompare

[ Source](https://github.com/revenuewire/translation)[ Packagist](https://packagist.org/packages/rw/translation)[ Docs](https://github.com/cosmostail/translation)[ RSS](/packages/rw-translation/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (73)Used By (0)

[![Build Status](https://camo.githubusercontent.com/30ef5e2c72c9b56035fdc685b1d053115e0c3adf74db6fe11eb61d564a71e8ff/68747470733a2f2f7472617669732d63692e6f72672f726576656e7565776972652f7472616e736c6174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/revenuewire/translation)[![Coverage Status](https://camo.githubusercontent.com/6f3c84d95891580d4d0a30ca07026eb0c1ae48f58a602e2356b99b53185afe29/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f726576656e7565776972652f7472616e736c6174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/revenuewire/translation?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/6442781cc0a1a5eaf62de678634699b330621de1f60d80dd32fe434aa25b03c7/68747470733a2f2f706f7365722e707567782e6f72672f726576656e7565776972652f7472616e736c6174696f6e2f762f737461626c65)](https://packagist.org/packages/revenuewire/translation)

Install
-------

[](#install)

`composer require revenuewire/translation`

Description
-----------

[](#description)

Translation Services using DyanmoDB or Redis as cache options. We also embedded two translation service providers, [One Hour Translation](https://www.onehourtranslation.com/)and [Google Cloud Translation](https://cloud.google.com/translate/).

**OneHourTranslation** provides human translators to translate your project where **Google Cloud Translation**charges a flat fee for [Neural Machine Translation (NMT)](https://research.googleblog.com/2016/09/a-neural-network-for-machine.html). Both service providers provide simple machine translation but are not supported for the purpose of this project.

Requirements
------------

[](#requirements)

Generally, there are two modes (live or db) of configurations you can choose from.

##### Live Mode

[](#live-mode)

Live mode uses **Google Cloud Translation** APIs that translate the texts directly to targeted languages. You need a Google Cloud account and key in order to use it. You also need **Redis** cache for better performance. No **memcached** support yet.

###### Requirement Summary

[](#requirement-summary)

- Google Cloud Account
- Redis

##### DB Mode

[](#db-mode)

Database mode uses **AWS DynamoDB** as a storage choice. **Redis** is suggested but not required.

###### Requirement Summary

[](#requirement-summary-1)

- AWS DynamoDB
- Redis (optional)

Configurations
--------------

[](#configurations)

##### Live Mode

[](#live-mode-1)

```
$defaultLanguage = "en";
$supportLanguages = ["en", "fr", "zh"];
$redisConfig = [
    "host" => "REDIS_HOST",
    "timeout" => "0.5",
    "port" => "6379",
    "prefix" => "t_2sx_", //optional, to prevent cache key collision
];
$gct = [
    "project" => "GOOGLE_CLOUD_PROJECT_ID",
    "key" => "GOOGLE_CLOUD_PROJECT_KEY"
];
$translationService = new \RW\Translation(null, $supportLanguages, $cache, $defaultLanguage, $gct);

//translate to Simple Chinese
echo $translationService->translate("Hello World", "zh");
print_r($translationService->batchTranslate([
   "hello" => "Hello World",
   "how-s-going" => "How's going?"
],"zh"));
```

##### DB Mode

[](#db-mode-1)

###### Install

[](#install-1)

```
php vendor/revenuewire/translation/bin/cli.php \
    --region=[AWS_REGION] \
    --translation=[TRANSLATION_TABLE] \
    --translation_queue=[TRANSLATION_QUEUE_TABLE] \
    --translation_project=[TRANSLATION_PROJECT_TABLE] \
    init
```

###### Usage

[](#usage)

```
$defaultLanguage = "en";
$supportLanguages = ["en", "fr", "zh"];

$dynamoConfig = [
   "region" => "us-west-2",
   "table" => "YOUR TABLE NAME",
   "version" => "2012-08-10"
];

$redisConfig = [
    "host" => "YOUR REDIS HOST",
    "timeout" => "0.5",
    "port" => "6379",
    "prefix" => "t_2sx_", //optional, to prevent cache key collision
];

$translationService = new \RW\Translation($dynamoConfig, $supportLanguages, $cache, $defaultLanguage);

//translate to Simple Chinese
echo $translationService->translate("Hello World", "zh");
print_r($translationService->batchTranslate([
   "hello" => "Hello World",
   "how-s-going" => "How's going?"
],"zh"));
```

Working with Translation Services
---------------------------------

[](#working-with-translation-services)

Once you go through all your pages, your translation table should have collected all texts you need to translate.

###### diff

[](#diff)

Calculate the difference between existing texts and targeted translation texts. For example, if your source table have a English word "Hello World", and the following command will generate two queue items that aim to translate "Hello World" to Chinese and French.

```
php vendor/revenuewire/translation/bin/cli.php \
        --provider=[OTH or GCT] \
        --region=[AWS_REGION] \
        --translation=[TRANSLATION_TABLE] \
        --translation_queue=[TRANSLATION_QUEUE_TABLE] \
        --translation_project=[TRANSLATION_PROJECT_TABLE] \
   	    diff zh fr
```

###### add

[](#add)

The add command will add all pending items into projects. This is useful when working with OneHourTranslation which had limits on how many texts you can schedule to translate per batch.

```
php vendor/revenuewire/translation/bin/cli.php \
        --region=[AWS_REGION] \
        --translation=[TRANSLATION_TABLE] \
        --translation_queue=[TRANSLATION_QUEUE_TABLE] \
        --translation_project=[TRANSLATION_PROJECT_TABLE] \
        --oth_pubkey=[ONE_HOUR_TRANSLATION_PUB_KEY] \
        --oth_secret=[ONE_HOUR_TRANSLATION_SECRET] \
        --oth_sandbox=[ONE_HOUR_TRANSLATION_SANDBOX] \
        --gct_project=[GOOGLE_CLOUD_PROJECT] \
        --gct_key=[GOOGLE_CLOUD_KEY] \
        add
```

###### commit

[](#commit)

Commit the projects to service provider. The commit only available for One Hour Translation.

```
php vendor/revenuewire/translation/bin/cli.php \
        --region=[AWS_REGION] \
        --translation=[TRANSLATION_TABLE] \
        --translation_queue=[TRANSLATION_QUEUE_TABLE] \
        --translation_project=[TRANSLATION_PROJECT_TABLE] \
        --oth_pubkey=[ONE_HOUR_TRANSLATION_PUB_KEY] \
        --oth_secret=[ONE_HOUR_TRANSLATION_SECRET] \
        --oth_sandbox=[ONE_HOUR_TRANSLATION_SANDBOX] \
        commit
```

###### push

[](#push)

Push the translated texts back to translation table.

```
php vendor/revenuewire/translation/bin/cli.php \
        --region=[AWS_REGION] \
        --translation=[TRANSLATION_TABLE] \
        --translation_queue=[TRANSLATION_QUEUE_TABLE] \
        --translation_project=[TRANSLATION_PROJECT_TABLE] \
   	    push
```

Languages Support
-----------------

[](#languages-support)

Most language code parameters conform to ISO-639-1 identifiers, except where noted.

CodeGoogle Cloud TranslationOne Hour TranslationLanguageDisplayNoteenenen-usEnglishEnglishafafafAfrikaansAfrikaansararar-saArabicالعربيةbgbgbg-bgBulgarianБългарскиzhzhzh-cn-cmn-sChinese (Simple)简体中文zh-cnzh-cnzh-cn-cmn-sChinese (Simple)简体中文BCP-47zh-twzh-twzh-cn-cmn-tChinese (Traditional)繁體中文BCP-47hrhrhr-hrCroatianhrvatskicscscs-czCzechčeskýdadada-dkDanishdansknlnlnl-nlDutchNederlandsfrfrfr-frFrenchfrançaisdedede-deGermanDeutschelelel-grGreekελληνικάiwiwN/AHebrewעבריתhihihi-inHindiहिन्दीisisis-isIcelandicíslenskaididid-idIndonesianBahasa Indonesiaititit-itItalianitalianojajajp-jpJapanese日本語kokoko-kpKorean한국어nonono-noNorwegianNorskplplpl-plPolishpolskiptptpt-ptPortugueseportuguêspt-brN/Apt-brPortuguese (Brazil)português - BrasilISO 639.2pt-ptptpt-ptPortuguese (Portugal)portuguêsISO 639.2rororo-roRomanianlimba românărururu-ruRussianРусскийsksksk-skSlovakslovenčinaeseses-esSpanishespañolsvsvsv-seSwedishsvenskaththth-thThaiภาษาไทยtrtrtr-trTurkishTürkçevivivi-vnVietnameseTiếng ViệtfiN/Afi-fiFinnishsuomi

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~252 days

Total

70

Last Release

532d ago

Major Versions

v3.1.3 → v4.0.02018-10-11

v2.0.2.x-dev → v3.1.4.x-dev2019-01-09

v3.1.4 → v4.0.12019-01-09

2.0.3 → 4.0.22023-02-01

4.0.2 → 5.0.02024-09-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/734c4a5502142de0958b3e298555f3991ee0fd3203995dfa8c0c218835e428f8?d=identicon)[swang](/maintainers/swang)

---

Top Contributors

[![cosmostail](https://avatars.githubusercontent.com/u/2172362?v=4)](https://github.com/cosmostail "cosmostail (3 commits)")[![lixinebo](https://avatars.githubusercontent.com/u/30449189?v=4)](https://github.com/lixinebo "lixinebo (2 commits)")[![yourGuy](https://avatars.githubusercontent.com/u/6990064?v=4)](https://github.com/yourGuy "yourGuy (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rw-translation/health.svg)

```
[![Health](https://phpackages.com/badges/rw-translation/health.svg)](https://phpackages.com/packages/rw-translation)
```

###  Alternatives

[lexik/translation-bundle

This bundle allows to import translation files content into the database and provide a GUI to edit translations.

4362.7M19](/packages/lexik-translation-bundle)[boxblinkracer/phpunuhi

Easy tool to work with translation files for validation, exports, imports and more.

83225.2k17](/packages/boxblinkracer-phpunuhi)[devitek/yaml-translation

Add YAML file support to Laravel TranslationServiceProvider

3345.0k2](/packages/devitek-yaml-translation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
