Language converter in php




















If you want to get a translated text, you have to change the URL of the request from the previous example. The rest of the code looks very similar:. If you decide not to include the source language the source parameter in the request, two scenarios can happen: 1. Google will manage to detect the language by itself, the JSON response will consequently contain an additional detectedSourceLanguage property holding the source language code.

The source language will not be successfully detected e. This leads to the next part of the tutorial — handling errors. If the response code is different than , it means that something went wrong. The Google Translate API can return following error codes: — Bad request — your request is missing some parameters or you have passed wrong values to the parameters present in the request e.

For example, when one of the required parameters is missing, the server will reply with a following response:. You can translate several texts in one request, which is undoubtedly more efficient than executing separate request for each translation. To do so, just pass a couple of q parameters, each containing one text to translate. However, it gets a little tricky here: — if your source texts are all of the same language, you can pass the source parameter containing the language code of all the texts; — but if you want to translate a couple of texts in different languages, you cannot pass several source parameters.

In such case you have to omit the source parameter and just let Google guess what the languages of the source texts are. It comes with the standard character encoding support which helps the script to change website in multiple languages. In Addition, it also supports the classical and historical text of any written language.

This Item comes with Developer License. You can use this item for multiple purposes. All rights reserved. Click Here. My Account. Product Description. Prominent Features Of Sirius — Language Translator PHP Script Available Language List This script comes with more than 23 languages to convert any particular website into the following languages: English Arabic Bulgarian Dutch French German And Many More… Moreover, this script is translation ready which means the site itself can be translated in multiple languages and it also supports multiple timezones formats.

Translation API Support This script has in-built support of robust translation APIs to provide a precise and accurate translation of different language text.

Translation Stats Translation stats show the precise numbers of characters and words that have been translated in a day or month. Ignore lock file. Mar 18, Add php 7. Jan 13, Oct 17, Add docs for setClient method.

Update composer. Dec 19, PHPUnit tests. Mar 19, View code. Topics php translation language-detection translate google-translate detect-language. Releases 13 v4. Sponsor this project patreon. Packages 0 No packages published. Used by 1. You signed in with another tab or window.



0コメント

  • 1000 / 1000