Feature Request: Multiple strings in JText::script() #31433
Replies: 3 comments
-
The proposed solution is half baked as the API has 3 arguments and the proposed one is ignoring the last 2. But it could be like: $texts = [
'COM_EXAMPLE_STRING' => [
'jsSafe' => true,
'interpretBackSlashes' => true
],
'COM_EXAMPLE_STRING_NEXT' => [
'jsSafe' => false,
'interpretBackSlashes' => false
],
// Or with defaults
'COM_EXAMPLE_STRING_WITH_DEFAULTS' => [],
]; My 2c |
Beta Was this translation helpful? Give feedback.
-
@dgrammatiko I intentionally omitted the other arguments, because providing an array of arrays doesn't necessarily simplify the input. Instead, you could just call the |
Beta Was this translation helpful? Give feedback.
-
Is it possible to do something simple like
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Current Procedure
Currently, to translate any Javascript string, we use the combination of
JText::script()
in PHP andJoomla.JText._()
in Javascript. However, it's common that we may want to include multiple strings to translate in Javascript. Currently, to do that, you have to write:Desired Procedure
This could be easily simplified to this:
Suggested change
This could be avoided, if the script function allowed arrays as input. A simple
if (is_array($string))
and a loop could do this.Beta Was this translation helpful? Give feedback.
All reactions