Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/riwert/gtranslator

Translate between multiple languages using Google Translate in PHP simple script.
https://github.com/riwert/gtranslator

curl google-translate php

Last synced: 2 days ago
JSON representation

Translate between multiple languages using Google Translate in PHP simple script.

Awesome Lists containing this project

README

        

# GTranslator
Translate between multiple languages using Google Translate.

## Usage
### Simple text translate
```
translateText($text);

```
### Translate array of translations and export to PHP file
```
[
'first' => 'Translate text.',
'second' => 'Translate array.',
'third' => 'Update file with translations.',
]
];

$gTranslator = new GTranslator($sourceLanguage, $targetLanguage);

$translations['pl'] = $gTranslator->translateArray($translations['en']);

$gTranslator->exportToPhpFile($translations, 'translations.php');

```

### Update PHP file with translations
```
updateTranslations('translations.php', ['pl', 'de', 'es']);

```
PHP file with translations:
```
// translations.php
[
'key' => 'Text to translate.',
],
];

```