Skip to content

Commit

Permalink
Partial port of #14 to stable-3_4_0
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed May 10, 2024
1 parent 2cacdb6 commit d546c11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CustomLocalePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function register($category, $path, $mainContextId = null): bool
*/
public function setupLocalizationOverriding(): void
{
Locale::registerPath(static::getStoragePath(), PHP_INT_MAX);
if (is_dir($path = static::getStoragePath())) Locale::registerPath($path, PHP_INT_MAX);
}

/**
Expand Down Expand Up @@ -166,7 +166,7 @@ public static function getTranslator(string $locale): Translator
public static function getContextFileManager(): ContextFileManager
{
$context = Application::get()->getRequest()->getContext();
return new ContextFileManager($context->getId());
return new ContextFileManager($context ? $context->getId() : Application::CONTEXT_SITE);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion controllers/grid/CustomLocaleGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public function initialize($request, $args = null): void
public function loadData($request, $filter): array
{
$gridDataElements = [];
$locales = $request->getContext()->getSupportedFormLocaleNames();
$context = $request->getContext();
$locales = $context ? $context->getSupportedFormLocaleNames() : $request->getSite()->getSupportedLocaleNames();
foreach (array_keys($locales) as $i => $locale) {
$gridDataElements[] = new CustomLocale($i, $locale, $locales[$locale]);
}
Expand Down

0 comments on commit d546c11

Please sign in to comment.