DEV Community

Raed Yak
Raed Yak

Posted on

1

Get To Know Mirza Yandex Translator For Laravel

Well, this is my first Laravel Package! :D

This package uses the Yandex.Translate API to translate text and provides several methods to make it easier to use the API!

Repo URL: https://github.com/yak0d3/Mirza_Yandex_Translator

Feedback is very appreciated!

Methods Table

Method Parameters Returns Throws Description
translate string $text string $lang Optional: string $format \[html or plain\] (Default: "Plain") String Exception: If text couldn't be translated. Translates a given $text to a given $lang (language)
translateTo string $text array $langs String (json) Exception: If one or more languages aren't supported. Translate a given $text to multiple $langs (languages)
translateArray array $textArray string $lang Optional: bool $assoc (Default: false) String (json) Exception:
1. If target language is not supported.
2. If $assoc is set to true and the given array is not associative.
Translates a $textArray (array of text) to a given $lang (language)
Note: If $assoc is set to true, the returned json string will have the same index names
detectLanguage string $text Optional: bool $langName String Exception: 1. If language code is not found. 2. If language name is not found Detects the language of a given $text and returns the language code Note: If $langName is set to true, the language full name will be returned instead.
getSupportedLanguages None String (json) Exception: If an unknown error occurs while trying to fetch the list of supported functions Returns a json string containing the list of all supported languages
translateToAll string $text String (json) None Translates a string ($text) to all supported languages. Note: This may take a while and cause a PHP max_execution_time TIMEOUT Exception
yandex_rights Optional: string $color (Default: #fff) string $fontsize (Default: 14px) String None Returns the string of the "Powered By Yandex.Translate" link string. Also called via blade directive @yandex_rights.
Note: Please refer to Yandex Translate: Requirements for the use of translation results to know more about font-size, color and placing requirements.
languages_select None String None Returns the string of an HTML <select> tag with the list of all available languages.
Also called via blade directive @languages_select

Blade Directives Table

Directive Parameters Description
@yandex_rights Optional: string $color (Default: #fff) string $fontsize (Default: 14px) Generates an HTML link for the "Powered By Yandex.Translate" text.
@languages_select None Generates an HTML <select> tag with the list of all available languages.
@translate string $text string $lang Translate a given $text string to a given $lang (language)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay