1. Go to this page and download the library: Download jasminecms/jasmine 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/ */
Jasmine::registerTranslationService('ai', function (string $source, string $target, array $values) {
$data = array_combine(array_keys($values), array_column($values, 'value'));
$lc2Label = function (string $lc) {
return match ($lc) {
'en' => 'English',
'he' => 'Hebrew',
default => $lc,
};
};
$fromLang = $lc2Label($source);
$toLang = $lc2Label($target);
$req = Prism::text()
->using(Provider::Gemini, 'gemini-2.0-flash')
->withMaxTokens(32768)
->withSystemPrompt(implode(' ', [
'You are a professional translator,',
'you try to use a gender neutral language when possible,',
'you have a good understanding of JSON objects',
'no notes, comments, explanations or other information, just JSON',
]))
->withMessages([
new UserMessage("Translate my JSON object from $fromLang to $toLang, translate all values only (not keys), leave any urls untouched"),
new UserMessage(json_encode($data, JSON_UNESCAPED_UNICODE)),
]);
$res = $req->asText();
preg_match('#\{(?:[^{}]|(?R))*\}#s', $res->text, $matches);
$translated = json_decode($matches[0] ?? '{}', true);
return $translated;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.