@@ -338,6 +338,7 @@ You can also define simple (boolean, integer or double) variables from inside th
338
338
if you dont want to copy & paste complex ``if `` expressions over and over again:
339
339
340
340
.. code-block :: twig
341
+ :force:
341
342
342
343
{% if expr1 %}
343
344
{% DEFINE $COLSPAN = 3 %}
@@ -372,3 +373,69 @@ User variables can be cleared (unset) using:
372
373
.. code-block :: twig
373
374
374
375
{% UNDEFINE $COLSPAN %}
376
+
377
+ Language variables
378
+ ------------------
379
+
380
+ You can use and interact with language variables in multiple ways. phpBB extends the standard twig syntax with the
381
+ following functions to be able to use language variables within twig based template code:
382
+
383
+ - ``lang ``
384
+ Get output for a language variable similar to using ``{{ L_FOO }} ``.
385
+ The following two lines output the same result:
386
+
387
+ .. code-block :: twig
388
+ :force:
389
+
390
+ {{ lang('FOO') }}
391
+ {{ L_FOO }}
392
+
393
+ It supports the same parameter syntax as ``$language->lang() ``:
394
+
395
+ .. code-block :: twig
396
+
397
+ {{ lang('SOME_VAR', param1, param2) }}
398
+
399
+ For language variables in Javascript, please use ``lang_js ``.
400
+
401
+ - ``lang_js ``
402
+ Get output for language variable in JS code. This should be used instead of the previously used ``LA_ `` prefix.
403
+ The following two lines output the same result:
404
+
405
+ .. code-block :: twig
406
+ :force:
407
+
408
+ {{ lang_js('FOO') }}
409
+ {{ LA_FOO }}
410
+
411
+ It supports the same parameter syntax as ``$language->lang() ``:
412
+
413
+ .. code-block :: twig
414
+
415
+ {{ lang_js('SOME_VAR', param1, param2) }}
416
+
417
+ Essentially this is the equivalent of:
418
+
419
+ .. code-block :: twig
420
+
421
+ {{ lang('SOME_VAR', param1, param2) | escape('js') }}
422
+
423
+ - ``lang_defined ``
424
+ Checks whether a language variable is defined. Can be used to check for existence of a language variable before
425
+ calling ``lang `` or ``lang_js ``.
426
+
427
+ .. code-block :: twig
428
+
429
+ {% if lang_defined('MY_LANG_VAR') %}
430
+ <span>{{ lang('MY_LANG_VAR') }}</span>
431
+ {% endif %}
432
+
433
+ - ``lang_raw ``
434
+ Outputs the raw value of a language variable, e.g. a string or array. It can be used to access entries of a language
435
+ array in the template code.
436
+
437
+ .. code-block :: twig
438
+
439
+ {% for step in lang_raw('EXTENSION_UPDATING_EXPLAIN') %}
440
+ <li>{{ step }}</li>
441
+ {% endfor %}
0 commit comments