Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bedita/i18n-google
Google translate plugin
https://github.com/bedita/i18n-google
Last synced: 21 days ago
JSON representation
Google translate plugin
- Host: GitHub
- URL: https://github.com/bedita/i18n-google
- Owner: bedita
- License: lgpl-3.0
- Created: 2023-11-06T16:20:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-17T11:46:53.000Z (8 months ago)
- Last Synced: 2024-11-25T14:51:59.936Z (28 days ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.LGPL
Awesome Lists containing this project
README
# BEdita I18n Google plugin
[![Github Actions](https://github.com/bedita/i18n-google/workflows/php/badge.svg)](https://github.com/bedita/i18n-google/actions?query=workflow%3Aphp)
[![codecov](https://codecov.io/gh/bedita/i18n-google/branch/main/graph/badge.svg)](https://codecov.io/gh/bedita/i18n-google)
[![phpstan](https://img.shields.io/badge/PHPStan-level%205-brightgreen.svg)](https://phpstan.org)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bedita/i18n-google/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/bedita/i18n-google/?branch=main)
[![image](https://img.shields.io/packagist/v/bedita/i18n-google.svg?label=stable)](https://packagist.org/packages/bedita/i18n-google)
[![image](https://img.shields.io/github/license/bedita/i18n-google.svg)](https://github.com/bedita/i18n-google/blob/main/LICENSE.LGPL)## Installation
You can install this plugin into your application using [composer](https://getcomposer.org).
The recommended way to install composer packages is:
```
composer require bedita/i18n-google
```Note: php version supported is >= 7.4.
## Google Cloud Translation
This plugin uses [Google Cloud Translation for PHP](https://cloud.google.com/php/docs/reference/cloud-translate/latest) to translate texts, via [google-cloud-php-translate](https://github.com/googleapis/google-cloud-php-translate).
Usage example:
```php
use BEdita\I18n\Google\Core\Translator;$translator = new Translator();
$translator->setup(['auth_key' => 'your-auth-key']);
$result = $translator->translate(['Hello world!'], 'en', 'it');
// $result is an array, i.e ['translation' => ['Ciao mondo!']]
```