Skip to content

Commit 73432f8

Browse files
committed
[FrameworkBundle] Allow dots in translation domains
1 parent fb4d928 commit 73432f8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,14 +1217,15 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
12171217
->followLinks()
12181218
->files()
12191219
->filter(function (\SplFileInfo $file) {
1220-
return 2 === substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
1220+
return 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
12211221
})
12221222
->in($dirs)
12231223
->sortByName()
12241224
;
12251225

12261226
foreach ($finder as $file) {
1227-
list(, $locale) = explode('.', $file->getBasename(), 3);
1227+
$fileNameParts = explode('.', basename($file));
1228+
$locale = $fileNameParts[\count($fileNameParts) - 2];
12281229
if (!isset($files[$locale])) {
12291230
$files[$locale] = [];
12301231
}

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ private function addResourceFiles($filesByLocale)
148148
foreach ($filesByLocale as $locale => $files) {
149149
foreach ($files as $key => $file) {
150150
// filename is domain.locale.format
151-
list($domain, $locale, $format) = explode('.', basename($file), 3);
151+
$fileNameParts = explode('.', basename($file));
152+
$format = $fileNameParts[\count($fileNameParts) - 1];
153+
$locale = $fileNameParts[\count($fileNameParts) - 2];
154+
$domainParts = array_splice($fileNameParts, 0, \count($fileNameParts) - 2);
155+
$domain = implode('.', $domainParts);
152156
$this->addResource($format, $file, $locale, $domain);
153157
}
154158
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy