Download the PHP package atran/translate without Composer
On this page you can find all versions of the php package atran/translate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download atran/translate
More information about atran/translate
Files in atran/translate
Package translate
Short Description Making Microsoft translator API version 3 consumption easier in Laravel 5+.
License Unlicense
Homepage https://github.com/InputOutputZ/ATran
Informations about the package translate
ATran
Making Microsoft translator API version 3 consumption easier in Laravel 5+.
Through this integration you can do the following
- Detects text information such as language code and script. Refer to ATran@detectTextInformation.
- Detects list of text information such as language code and script. Refer to ATran@detectTextsInformation.
- Translates text from one language to one or multiple languages. Refer to ATran@translateText.
- Produces transliteration of text from one language to another. Refer to ATran@transliterateTextInformation.
- Request available languages for translation including list of languages code. Refer to ATran@translationsAvailable.
- Request available languages for transliteration including list of available scripts. Refer to ATran@transliterationAvailable.
Laravel Microsoft Translator Integration
There are 3 files to have a look at so to understand how the integration works
- config/atran.php (Configuration of API endpoints & authorisation key)
- routes.php (Configuring PlayWithAPIController routes)
- ATran\Translate\PlayWithAPIController (A Controller with on hand methods playing with the API endpoints)
Required Packages
Installation for Laravel 5+. Tested on 8.40.
-
1- Go to your laravel project root directory and install the package locally:-
-
2- Install the service provider and load config as well as routes references:-
-
3- Choose "ATran\Translate\ATranServiceProvider" provider from the list via typing its index value.
-
4- Go to env file and include at the bottom:-
- 5- Well Done!
Installation for older Laravel
You may expect more debugging to get it working.
-
1- Go to your laravel project root directory and install the package locally:-
-
2- Add ATran service provider manually to the providers list in config/app.php:-
-
3- Load config as well as routes references:-
-
4- Go to env file and include at the bottom:-
- 5- Well Done!
Demo with PlayWithAPIController and Postman
Configuration
- Codebase Configuration
-1 Go To PlayWithAPIController
-2 Go to definition of detectTextInformation and transliterationsAvailable.
-3 Examine the functions
- detectTextInformation | Postman Configuration to route "http://yourwebsite.com/detecttext" and POST type.
-1 Include following headers:-
2- Include following Body: form-data
3- Response
- transliterationsAvailable | Postman Configuration to route "http://yourwebsite.com/transliterationavailable" and POST type.
-1 Include following headers:-
2- Response
Usage
Import Use at the top in any of your laravel project controllers
Access functions through
Available functions
- detectTextInformation($text)
- detectTextsInformation($texts)
- transliterateTextInformation($text,$language,$fromscript,$toscript)
- translateText($text, $to)
- transliterationsAvailable($languagecode = null)
- translationsAvailable($languagecode = null)
About
The ATran package was published under The Unlicense licence. If you have any problems, please feel free to reach out at [email protected].