8000 feature #32548 [Translation] XliffLintCommand: allow .xliff file exte… · symfony/symfony@d6773bc · GitHub
[go: up one dir, main page]

Skip to content

Commit d6773bc

Browse files
feature #32548 [Translation] XliffLintCommand: allow .xliff file extension (codegain)
This PR was merged into the 4.4 branch. Discussion ---------- [Translation] XliffLintCommand: allow .xliff file extension | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | License | MIT I ran into a problem with XLIFF files having an *.xliff extension and a "target-language" attribute. The command always outputted: There is a mismatch between the language included in the file name and the value used used in the "target-language" attribute of the file. The "target-language" attribute was set to "en" and the filename was also "menu.en.xliff". After reading the source code, I realized that this regex does not respect other valied file extensions such as "xliff" for these files and therefore throws this (rather confusing) error. Commits ------- dba6a21 [Translation] XliffLintCommand: allow .xliff file extension
2 parents 44f6e94 + dba6a21 commit d6773bc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Translation/Command/XliffLintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private function validate(string $content, $file = null)
126126
// otherwise, both '____.locale.xlf' and 'locale.____.xlf' are allowed
127127
// also, the regexp matching must be case-insensitive, as defined for 'target-language' values
128128
// http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target-language
129-
$expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.xlf/', $normalizedLocale) : sprintf('/^(.*\.(?i:%s)\.xlf|(?i:%s)\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
129+
$expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.(?:xlf|xliff)/', $normalizedLocale) : sprintf('/^(?:.*\.(?i:%s)|(?i:%s)\..*)\.(?:xlf|xliff)/', $normalizedLocale, $normalizedLocale);
130130

131131
if (0 === preg_match($expectedFilenamePattern, basename($file))) {
132132
$errors[] = [

0 commit comments

Comments
 (0)
0