1
0
mirror of https://github.com/flarum/core.git synced 2025-10-11 23:14:29 +02:00

Switch to ICU MessageFormat (#2759)

This commit is contained in:
Alexander Skvortsov
2021-04-30 12:44:39 -04:00
committed by GitHub
parent edaf45d133
commit b45519974a
24 changed files with 19152 additions and 3351 deletions

View File

@@ -17,6 +17,7 @@ use Illuminate\Contracts\Container\Container;
use InvalidArgumentException;
use RuntimeException;
use SplFileInfo;
use Symfony\Component\Translation\MessageCatalogueInterface;
class LanguagePack implements ExtenderInterface, LifecycleInterface
{
@@ -107,6 +108,9 @@ class LanguagePack implements ExtenderInterface, LifecycleInterface
// extension) with the list of known names and all extension IDs.
$slug = $file->getBasename(".{$file->getExtension()}");
// Ignore ICU MessageFormat suffixes.
$slug = str_replace(MessageCatalogueInterface::INTL_DOMAIN_SUFFIX, '', $slug);
if (in_array($slug, self::CORE_LOCALE_FILES, true)) {
return true;
}

View File

@@ -13,6 +13,7 @@ use DirectoryIterator;
use Flarum\Extension\Extension;
use Flarum\Locale\LocaleManager;
use Illuminate\Contracts\Container\Container;
use Symfony\Component\Translation\MessageCatalogueInterface;
class Locales implements ExtenderInterface, LifecycleInterface
{
@@ -38,8 +39,14 @@ class Locales implements ExtenderInterface, LifecycleInterface
continue;
}
$intlIcu = false;
$locale = $file->getBasename(".$extension");
// Ignore ICU MessageFormat suffixes.
$locale = str_replace(MessageCatalogueInterface::INTL_DOMAIN_SUFFIX, '', $locale);
$locales->addTranslations(
$file->getBasename(".$extension"),
$locale,
$file->getPathname()
);
}