-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Improve an error message related to Xliff translation files #11256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imo, the error is spot on. However, there are other problems:
Because of (1), (2) and (4), Symfony should recommend to use the more simpler Yaml translation files instead of Xliff. In the usage of Symfony, Xliff doesn't add any value. It only causes bad xliff files and lots of errors. (3) can be solved in 2 ways afaics: (a) Not throw a twig exception when a template could not be rendered because of an exception or (b) avoid logging the twig exception if there is a previous exception. Now, why the DTD exception is correct: The The fix is available in the XLIFF representation guide:
But the |
@wouterj thanks for explaining with great detail this problem and their possible solutions. In my personal projects I usually solve this problem using <trans-unit id="serializer.summary">
<source>serializer.summary</source>
<target><![CDATA[
Převádí objekty do různých formátů (XML, JSON, Yaml, …)
a zpětně z nich je načítá.
]]></target>
</trans-unit> What do you think of this solution? |
It's simple, but I always look at CDATA the same as fixing "header already sent" errors with What CDATA does is saying to XML: Skip this section and just pass it through. So if you use CDATA a lot, you can almost say that you are no longer parsing the XML file, you are just passing bytes through. |
@wouterj But in this case, this is exactly the behavior we expect: the XML parser should not care about the translation itself and what characters are used, this is indeed just a set of bytes for it. |
… (hhamon) This PR was merged into the 2.3 branch. Discussion ---------- [Translation] made XliffFileDumper support CDATA sections. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | maybe | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11256 | License | MIT Commits ------- 9926845 [Translation] made XliffFileDumper support CDATA sections.
This should be closed. It can't be improved. The only way to improve the experience is by not recommending Xliff anymore... |
Closing it as suggested by @wouterj. |
The problem
A few days ago @hason reported an error with the Czech translation of symfony.com (see symfony/marketing#167)
After forcing the error locally, this was the error message showed by Symfony:
The problem is that this error message is very misleading. Whereas the error suggests problems with Twig templates and DTDs, the real problem is about using HTML entities in Xliff files (see the commit that fixed this error).
The solution
Improve this error message to correctly guide the user towards the real cause of the error.
The text was updated successfully, but these errors were encountered: