https://github.com/thejano/text-translator
This package allows to translate text using Google Translator for free without api.
https://github.com/thejano/text-translator
api google php translation translator
Last synced: 5 months ago
JSON representation
This package allows to translate text using Google Translator for free without api.
- Host: GitHub
- URL: https://github.com/thejano/text-translator
- Owner: thejano
- License: mit
- Created: 2022-10-06T01:08:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-13T19:58:32.000Z (11 months ago)
- Last Synced: 2025-10-25T22:13:43.649Z (8 months ago)
- Topics: api, google, php, translation, translator
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 4
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Text Translator for PHP
[](https://packagist.org/packages/thejano/text-translator)
[](https://packagist.org/packages/thejano/text-translator)
This package allows text translation using Google Translate for free without an API. It extracts the translated text from the Google Translate website. Meanwhile, it only supports Google Translate.
Supported Languages for Google Translate
https://cloud.google.com/translate/docs/languages
## Requirement
The package requires:
- PHP 8.0 or higher
## Installation
You can install the package via composer:
```bash
composer require thejano/text-translator
```
## Usage
You can use the package like below example
```php
translate($text,'ckb'); // ckb stands for Kurdish Sorani language
echo $translated; // Prints سڵاو جیهان
# Or Call statically
GoogleTranslator::translate($text,'ckb');
# Translate from Arabic to English
GoogleTranslator::translate('مرحبا بالعالم','en','ar'); // will returns Hello World
```
The class `GoogleTranslator` by default the source language is set to Auto, also you can override and provide target language on initiation.
```php
new GoogleTranslator(string $sourceLanguage = 'auto', string $targetLanguage = '')
```
The `translate` method can be called statically or non statically, and it accepts three parameters, which are:
```php
public function _translate(string $text, string $targetLanguage = '', string $sourceLanguage = ''): string;
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
- [Dr Pshtiwan](https://github.com/drpshtiwan)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.