Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add extra_requirements_i18n config to LeftAndMain #1678

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading