Wallogit.com
2017 © Pedro PelĂĄez
WikiDiki lets you translate words (mostly nouns) across multiple languages based on wikipedia.org
WikiDiki uses Wikipedia to translate words across multiple languages., (*1)
You can install the library using composer., (*3)
composer require maciejkrol/wikidiki
WikiDiki usage is super simple., (*4)
//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., (*5)
This way you will get all the available translations as an associative array with the language codes as keys., (*6)
$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., (*7)
$word = 'Tea'; $language = 'en'; $to = 'pl'; $translated = $wikidiki->translate($word, $language, $to); //string
or an array to retrieve an array of translations., (*8)
$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;, (*9)
From now on you can get search suggestions:, (*10)
$word = 'Tea'; $language = 'en'; $translated = $wikidiki->suggest($word, $language, $to); //array