1. Go to this page and download the library: Download firewire/fluency library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
firewire / fluency example snippets
// Get the current language's ISO code
$fluency->getLanguageCode(); // => en-us
// Get the ISO code for another language using it's ProcessWire ID
$fluency->getLanguageCode(1034); // 'de'
$translation = $fluency->translate(
sourceLanguage: 'EN', // Language code used by the translation service
targetLanguage: 'DE', // Language code used by the translation service
content: 'How do you do fellow developers?', // String or array of strings to translate
options: [], // Translation Engine specific options (optional)
caching: true // Default is true, false disables, overrides module config
); // => EngineTranslationData
// Results may be accessed via properties on the return object, see toArray() example below for all
// properties present in the EngineTranslationData object
$translation->translations; // => ['Wie geht es Ihnen, liebe Entwickler?']
$translation->fromCache; // => true
// $translation->toArray(); Outputs the following:
//
// array(10) {
// 'sourceLanguage' => 'EN'
// 'targetLanguage' => 'DE'
// 'content' => [
// 'How do you do fellow developers?'
// ],
// 'translations' => [
// 'Wie geht es Ihnen, liebe Entwickler?'
// ],
// 'options' => [],
// 'fromCache' => true,
// 'cacheKey' => 'ff6050ab0d048f7296214bfb21f18af707954dabf4df8013f3f013bc7382a73f',
// 'retrievedAt' => '2023-09-17T17:16:25-07:00',
// 'error' => NULL,
// 'message' => NULL,
// }
// Get the total number of translated strings returned
count($translation); // 1
$translation = $fluency->translate(sourceLanguage: 'EN', targetLanguage: 'DE', content: [
'Must it be?',
'It must be.',
]); // => EngineTranslationData
// $translation->toArray(); Outputs the following:
//
// array(10) {
// 'sourceLanguage' => 'EN'
// 'targetLanguage' => 'DE'
// 'content' => [
// 'Must it be?',
// 'It must be.'
// ],
// 'translations' => [
// 'Muss das sein?',
// 'Es muss sein.'
// ],
// 'options' => [],
// 'fromCache' => true,
// 'cacheKey' => '18af707954dabf4df8013f3f013bc7382a73fff6050ab0d048f7296214bfb21f',
// 'retrievedAt' => '2023-09-17T17:16:25-07:00',
// 'error' => NULL,
// 'message' => NULL,
// }
//
// Get the total number of translated strings returned
count($translation); // 2
// Get the current number of cached translations:
$fluency->getCachedTranslationCount(); // Int
// Clear the translation cache:
$fluency->clearTranslationCache(); // 0 on success
// Check if the list of languages translatable by the translation engine are currently cached:
$fluency->translatableLanguagesAreCached(); // Bool
// Clear the translatable languages cache:
$fluency->clearTranslatableLanguagesCache(); // 0 on success