maciejkrol/wikidiki

WikiDiki lets you translate words (mostly nouns) across multiple languages based on wikipedia.org

1.0.2 2016-07-25 10:40 UTC

This package is not auto-updated.

Last update: 2024-11-21 02:44:22 UTC


README

WikiDiki uses Wikipedia to translate words across multiple languages.

Installation

Total Downloads

You can install the library using composer.

composer require maciejkrol/wikidiki

Basic usage

WikiDiki usage is super simple.

//instantiate
$wikidiki = new \maciejkrol\wikidiki\wikidiki ();

When translating you must tell WikiDiki what is the base language. English in this case. WikiDiki uses ISO two letter language codes.

This way you will get all the available translations as an associative array with the language codes as keys.

$word       =   'Tea';
$language   =   'en';

$translated = $wikidiki->translate($word, $language);   //array

You can also provide a third argument, a string with a single language code to get a single translated string.

$word       =   'Tea';
$language   =   'en';
$to         =   'pl';

$translated = $wikidiki->translate($word, $language, $to);   //string

or an array to retrieve an array of translations.

$word       =   'Tea';
$language   =   'en';
$to         =   ['pl', 'it'];

$translated = $wikidiki->translate($word, $language, $to);   //array

In case WikiDiki can't find a translation null will be returned;

From now on you can get search suggestions:

$word       =   'Tea';
$language   =   'en';

$translated = $wikidiki->suggest($word, $language, $to);   //array