Skip to content

Commit 874f231

Browse files
authored
Text::script should update existing script strings (joomla#41543)
* Text::script should update existing script strings * Text::script should update existing script strings * comment
1 parent e5c91e0 commit 874f231

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

libraries/src/Language/Text.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,21 @@ public static function script($string = null, $jsSafe = false, $interpretBackSla
351351

352352
// Add the string to the array if not null.
353353
if ($string !== null) {
354+
$doc = Factory::getDocument();
355+
356+
// Get previously added strings
357+
$strings = $doc->getScriptOptions('joomla.jtext');
358+
354359
// Normalize the key and translate the string.
355-
static::$strings[strtoupper($string)] = Factory::getLanguage()->_($string, $jsSafe, $interpretBackSlashes);
360+
$key = strtoupper($string);
361+
$strings[$key] = Factory::getLanguage()->_($string, $jsSafe, $interpretBackSlashes);
362+
static::$strings[$key] = $strings[$key];
356363

357364
// Load core.js dependency
358365
HTMLHelper::_('behavior.core');
359366

360367
// Update Joomla.Text script options
361-
Factory::getDocument()->addScriptOptions('joomla.jtext', static::$strings, false);
368+
$doc->addScriptOptions('joomla.jtext', $strings, false);
362369
}
363370

364371
return static::getScriptStrings();

0 commit comments

Comments
 (0)