PHPackages                             gabrieljmj/translator - 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. gabrieljmj/translator

ActiveLibrary[Localization &amp; i18n](/categories/localization)

gabrieljmj/translator
=====================

Translator to strings using APIs or other things

182131PHP

Since Dec 28Pushed 11y ago1 watchersCompare

[ Source](https://github.com/GabrielJMJ/Translator)[ Packagist](https://packagist.org/packages/gabrieljmj/translator)[ RSS](/packages/gabrieljmj-translator/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (1)

Translator
==========

[](#translator)

[!\[Gitter\](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/GabrielJMJ/Translator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![Total Downloads](https://camo.githubusercontent.com/58198f04918dda9073339223dfcf6c29148c3c2cc2abf1582ab9c6ccf3d882f3/68747470733a2f2f706f7365722e707567782e6f72672f6761627269656c6a6d6a2f7472616e736c61746f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/gabrieljmj/translator) [![Latest Unstable Version](https://camo.githubusercontent.com/de7add33157037cb6836a0b720b613c481b183b774860c031282c7a1fd1b2606/68747470733a2f2f706f7365722e707567782e6f72672f6761627269656c6a6d6a2f7472616e736c61746f722f762f756e737461626c652e706e67)](https://packagist.org/packages/gabrieljmj/translator) [![License](https://camo.githubusercontent.com/da5ce0917a8cd24f4551166ed4c61f5a41c95b8065670341812c68c5bffc740b/68747470733a2f2f706f7365722e707567782e6f72672f6761627269656c6a6d6a2f7472616e736c61746f722f6c6963656e73652e706e67)](https://packagist.org/packages/gabrieljmj/translator) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/16c1a4a96583762446392b3b90055f24bff1e100887ae6359aac8bd5cf799d7b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4761627269656c4a4d4a2f5472616e736c61746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GabrielJMJ/Translator/?branch=master)

Translator to texts using Web Services or other things that can do this action. ##Install ###Composer

```
{
  "require": {
    "gabrieljmj/translator": "dev-master"
  }
}
```

\##Needs

- [cURL extension](http://php.net/manual/pt_BR/book.curl.php) to do the web services requests.

\##Support ###Google Translate - Not tested To use the Google Translate, it is necessary an API Key. To create one, follow this steps:

- Go to the [Google Developers Console](https://console.developers.google.com/).
- Select a project, or create a new one.
- In the sidebar on the left, select **APIs &amp; auth**. In the list of APIs, make sure the status is **ON** for the Google Translate API.
- In the sidebar on the left, select **Credentials**.

**How to instance:** `new \Translator\Service\GoogleTranslate(\Translator\Http\RequestInterface $request, string $apiKey)`

\###Yandex Translate - Tested To use, also is necessary an API Key.

- Go to [API key request form](http://api.yandex.com/key/form.xml?service=trnsl).
- After create, go to [My keys](http://api.yandex.com/key/keyslist.xml).

**How to instance:** `new \Translator\Service\YandexTranslate(\Translator\Http\RequestInterface $request, string $apiKey)`

\##How to use Examples with Google Translate ###Getting accepted languages of a web service Use the method `getAcceptedLangs()`. It will return an array with all languages accepted by web service that you are using.

\###Translating

```
use Translator\Service\GoogleTranslate;
use Translator\Http\CurlRequest;

$text = 'Hi! How are you?';
$apiKey = 'YOUR_API_KEY';

$translator = new GoogleTranslate(new CurlRequest(), $apiKey);
$translatedText = $translator->translate('en', 'pt', $text);
$translatedText->getNewText();//'Oi! Como vai você?'
$translatedText->getOriginalText();//'Hi! How are you?'
$translatedText->getOriginalLang();//en
$translatedText->getNewLang();//pt
```

With an array:

```
$texts = array('Hi!', 'How are you?');

$translatedText = $translator->translate('en', 'pt', $texts);
$translatedText->getNewText();//Array('Oi!', 'Como vai você?')
$translatedText->getOriginalText();//Array('Hi!', 'How are you?')
$translatedText->getOriginalLang();//en
$translatedText->getNewLang();//pt
```

\###Detecting language

```
$detectedText = $translator->detect($text);
$detectedText->getLang();//en
$detectedText->getText()//Hi! How are you?
$detectedText->getDetectedTextWithLang();//Array('Hi! How are you?' => 'en')
```

With an array:

```
$texts = array('Hi!', 'Olá!');

$detectedText = $translator->detect($texts);
$detectedText->getLang();//Array('en', 'pt')
$detectedText->getText();//Array('Hi!', 'Olá!')
$detectedText->getDetectedTextWithLang();//Array('Hi!' => 'en', 'Olá!' => 'pt')
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.4% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fcbdf815749595d3dcfd4fb781e2cac05aa6d132123aa9da889d2c5ca6c8e11?d=identicon)[GabrielJMJ](/maintainers/GabrielJMJ)

---

Top Contributors

[![gabrieljmj](https://avatars.githubusercontent.com/u/2223216?v=4)](https://github.com/gabrieljmj "gabrieljmj (62 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

### Embed Badge

![Health badge](/badges/gabrieljmj-translator/health.svg)

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.8k](/packages/laradevs-spanish)

PHPackages © 2026

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