Merge branch '12100---collecte-dialogues-modules' into 12100

This commit is contained in:
Fred Tempez 2023-01-10 15:19:10 +01:00
commit 710f2cc2f0
3 changed files with 18 additions and 2 deletions

View File

@ -26,6 +26,16 @@ class helper
public static function translate($text) public static function translate($text)
{ {
$target = 'blog';
/** Collecte des dialogues des modules */
$url = $_SERVER['QUERY_STRING'];
$module = explode('/', $url);
if ($module === $target)
{
$dialogues = json_decode(file_get_contents('module/' . $target . '/i18n/fr_FR.json' ), true);
$data = array_merge($dialogues,[$text => '']);
file_put_contents ('module/' . $target . '/i18n/fr_FR.json', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX);
}
return (array_key_exists($text, core::$dialog) && !empty(core::$dialog[$text]) ? core::$dialog[$text] : $text); return (array_key_exists($text, core::$dialog) && !empty(core::$dialog[$text]) ? core::$dialog[$text] : $text);
} }

View File

@ -25,7 +25,10 @@ class template
'help' => '' 'help' => ''
], $attributes); ], $attributes);
// Traduction de l'aide et de l'étiquette // Traduction de l'aide et de l'étiquette
if (strpos($attributes['value'], '<span>') === 0 ) {
// Le contenu n'est pas une icône
$attributes['value'] = helper::translate($attributes['value']); $attributes['value'] = helper::translate($attributes['value']);
}
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
// Retourne le html // Retourne le html
return sprintf( return sprintf(
@ -752,7 +755,7 @@ class template
*/ */
public static function speech($text) public static function speech($text)
{ {
return '<div class="speech"><div class="speechBubble">' . $text . '</div>' . template::ico('mimi speechMimi', ['fontSize' => '7em']) . '</div>'; return '<div class="speech"><div class="speechBubble">' . helper::translate($text) . '</div>' . template::ico('mimi speechMimi', ['fontSize' => '7em']) . '</div>';
} }
/** /**

View File

@ -0,0 +1,3 @@
{
}