1. Go to this page and download the library: Download gabepri/auto-html-i18n 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/ */
gabepri / auto-html-i18n example snippets
use AutoHtmlI18n\I18nTranslator;
use AutoHtmlI18n\TranslationItem;
$i18n = new I18nTranslator([
'locale' => 'es',
'onMissingTranslation' => function (array $items, string $locale): array {
// $items: TranslationItem[] — one entry per unique missing key
// Return: ['masked_key' => 'translation', ...]
// Either look these up in your DB or hand them off to a translation service.
return MyTranslationService::fetch($items, $locale);
},
]);
$html = $i18n->translateHtml('<p>You have 5 apples</p>');
// → '<p>Tienes 5 manzanas</p>'