-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected: 4.4.19
Description
I am working on a Symfony application where I prefer to use full locales with language and region where language and region are separated by a dash (de-DE
) instead of an underscore as a separator (de_DE
).
The format using dashes
- conforms with https://tools.ietf.org/html/bcp47
- is widely used for identifying locales in frontend technologies
- is also supported by
ext/intl
(see https://www.php.net/manual/en/class.locale.php)
So far, the application works fine with locales in this format, except for the XliffLintCommand
.
How to reproduce
Running
$ bin/console lint:xliff translations/example.de-DE.xml
when an example file with the file name translations/example.de-DE.xml
contains
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="de-DE" target-language="de-DE" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
</body>
</file>
</xliff>
yields a misleading error message
ERROR in translations/example.de-DE.xlf
* There is a mismatch between the language included in the file name ("example.de-DE.xlf") and the "de-DE" value used in the "target-language" attribute of the file.
[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.
As far as I can tell, there is no mismatch.
Possible Solution
From here on I have the following options:
- I do not run the linting command anymore, possibly resulting in invalid translations.
- I rename the file from
translations/example.de-DE.xml
to `translations/example.de_DE.xml. This has the consequence that the translations are not loaded anymore. - I stop using locales that use a dash (
de-DE
) instead of an underscore as a separator (de_DE
). - I propose a pull request that fixes the problem.
❓ Would you accept a pull request that adjusts the XliffLintCommand
to account for users who prefer locales with a dash as a separator?
OskarStark