Skip to content

Commit

Permalink
NEW Add extra_requirements_i18n config to LeftAndMain (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Feb 13, 2024
1 parent dd9dcef commit 6d183e4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ class LeftAndMain extends Controller implements PermissionProvider
*/
private static $extra_requirements_javascript = [];

/**
* Register additional i18n requirements through the {@link Requirements} class.
*
* YAML configuration example:
* <code>
* LeftAndMain:
* extra_requirements_i18n:
* - mysite/client/lang
* 'myorg/mymodule:client/lang': true
* </code>
* @var array See {@link extra_requirements_javascript}
*/
private static array $extra_requirements_i18n = [];

/**
* YAML configuration example:
* <code>
Expand Down Expand Up @@ -723,6 +737,17 @@ protected function init()
}
}

$extraI18n = $this->config()->get('extra_requirements_i18n');
if ($extraI18n) {
foreach ($extraI18n as $dir => $return) {
if (is_numeric($dir)) {
$dir = $return;
$return = false;
}
Requirements::add_i18n_javascript($dir, $return);
}
}

$extraCss = $this->config()->get('extra_requirements_css');

if ($extraCss) {
Expand Down

0 comments on commit 6d183e4

Please sign in to comment.