PHPackages                             samsonos/google\_translate - 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. samsonos/google\_translate

ActiveLibrary

samsonos/google\_translate
==========================

Google Translte SamsonPHP module

0103PHP

Since Jan 22Pushed 11y ago2 watchersCompare

[ Source](https://github.com/samsonos/google_translate)[ Packagist](https://packagist.org/packages/samsonos/google_translate)[ RSS](/packages/samsonos-google-translate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SamsonPHP Google Translate API module
=====================================

[](#samsonphp-google-translate-api-module)

[![Latest Stable Version](https://camo.githubusercontent.com/67a0f1975bfc23e2bea10b1192c7a769ac2adacc47c2ec58cb11671b6294405e/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6f732f676f6f676c655f7472616e736c6174652f762f737461626c652e737667)](https://packagist.org/packages/samsonos/google_translate)[![Build Status](https://camo.githubusercontent.com/5c64378515e7366e644f2d4a9497716b39c7e101ff9d5c58a7ec078d7538dba4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e6f732f676f6f676c655f7472616e736c6174652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonos/google_translate/badges/build.png?b=master)[![Code Coverage](https://camo.githubusercontent.com/9c34cb23d6e3579cdd968b049d17c351ad285e21a925e4cee7ceccd89f5ed03e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e6f732f676f6f676c655f7472616e736c6174652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonos/google_translate/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/658b8c28147014f3ceb3952a4e8f78237bb0ea0312c24cf6445ebe1ae494399e/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6f732f676f6f676c655f7472616e736c6174652f646f776e6c6f6164732e737667)](https://packagist.org/packages/samsonos/google_translate)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e9dd15b034fbf849477424295a7ce5323eca2d7cb889eeac98ca843564ca8844/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e6f732f676f6f676c655f7472616e736c6174652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonos/google_translate/?branch=master)[![Stories in Ready](https://camo.githubusercontent.com/04d8167826d1754c374e63c4985bbf2eeb483895d5f2906ae8f5dccb043c8e66/68747470733a2f2f62616467652e776166666c652e696f2f73616d736f6e6f732f676f6f676c655f7472616e736c6174652e706e673f6c6162656c3d7265616479267469746c653d5265616479)](https://waffle.io/samsonos/google_translate)

\##Configuration

Before using translate module methods, you must create configuration and enter your Google API Key for using Google Translate API

All you need is create configuration class which is working thanks to [SamsonPHP module/service configuration](https://github.com/samsonphp/config):

```
class Google_TranslateConfig extends \samson\core\Config
{
    public $apiKey = 'Your_Google_API_Key';
}
```

Creating translate request
--------------------------

[](#creating-translate-request)

After creating configuration you can make request to Google Translate API. To create simple request you must define source language of you text and target language which you want to get. To identify languages you can use `source($source)` and `target($target)` methods.

For example you want to translate 'Hello World' to french:

```
/** @var \samson\google\Translate $trans Get SamsonPHP GoogleTranslate module */
$trans = m('google_translate');

// Source text
$helloWorld = 'Hello World';

// Translated text
$bonjourLeMonde = $trans->source('en')->target('fr')->trans($helloWorld);
```

Fixing translation errors
-------------------------

[](#fixing-translation-errors)

If you have some problems with API Key or you have make some errors in defining source or target locales, you will get error from Google Translate API. You can check status of your request using method `lastRequestStatus()`:

```
/** @var \samson\google\Translate $trans Get SamsonPHP GoogleTranslate module */
$trans = m('google_translate');

// Source text
$helloWorld = 'Hello World';

// Translated text
$bonjourLeMonde = $trans->source('gb')->target('fr')->trans($helloWorld);
// Is false, because gb locale is not found in Google language codes.

// Will return 'Invalid value'
echo $trans->lastRequestStatus();
```

This module is working using [Google Translate API](https://cloud.google.com/translate/)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.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/0be8756efdc8f599b8fe9261bed31570d0f140a3b921f0f891877a9133ad654c?d=identicon)[samsonos](/maintainers/samsonos)

---

Top Contributors

[![onysko](https://avatars.githubusercontent.com/u/7703953?v=4)](https://github.com/onysko "onysko (17 commits)")[![vitalyiegorov](https://avatars.githubusercontent.com/u/586558?v=4)](https://github.com/vitalyiegorov "vitalyiegorov (7 commits)")[![nik-os](https://avatars.githubusercontent.com/u/7326967?v=4)](https://github.com/nik-os "nik-os (2 commits)")

### Embed Badge

![Health badge](/badges/samsonos-google-translate/health.svg)

```
[![Health](https://phpackages.com/badges/samsonos-google-translate/health.svg)](https://phpackages.com/packages/samsonos-google-translate)
```

PHPackages © 2026

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