poeditor-android-gradle-plugin
poeditor-android-gradle-plugin copied to clipboard
The entity name must immediately follow the '&' in the entity reference
- Plug-in Version 3.4.0
As for the title the error message it's the same
"The entity name must immediately follow the '&' in the entity reference"
tested also on version 3.3.1 and this version doesn't have this issue.
Thanks
Hi @justodepp! Do you have any sample string that I can use to reproduce the error?
Thanks!
Hi Adrían, sure here one for example, "T & C" this one is inside the project the one coming from POEditor it's just something like this "T & C"
Saluti Gianni Andrea Cavalli
Il giorno gio 18 mag 2023 alle ore 17:40 Adrián García < @.***> ha scritto:
Hi @justodepp https://github.com/justodepp! Do you have any sample string that I can use to reproduce the error?
Thanks!
— Reply to this email directly, view it on GitHub https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/issues/66#issuecomment-1553248470, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6R4EW552BDYF3GIZTKBUTXGY7HJANCNFSM6AAAAAAYGFBWWE . You are receiving this because you were mentioned.Message ID: @.*** .com>
Had the same issue just now. Because of the same string :)
Hey @justodepp @carlosrivin! Sorry for replaying so late. I've been testing version 3.4.1 of the plug-in with these strings:
"test_issue_66_1" -> "T&C"
"test_issue_66_2" -> "T & C"
"test_issue_66_3" -> "T & C"
and got the following results:
<string name="test_issue_66_1">"T&C"</string>
<string name="test_issue_66_2">"T & C"</string>
<string name="test_issue_66_3">"T &amp; C"</string>
These should be the proper escape sequences so I believe the plugin is working as expected. Does the error happen when using the plugin or when compiling your apps?
Hello Adrián, thanks for replying! The error happen when using the plugin.
Ciao Gianni
Il giorno lun 28 ago 2023 alle ore 18:18 Adrián García < @.***> ha scritto:
Hey @justodepp https://github.com/justodepp @carlosrivin https://github.com/carlosrivin! Sorry for replaying so late. I've been testing version 3.4.1 of the plug-in with these strings:
"test_issue_66_1" -> "T&C" "test_issue_66_2" -> "T & C" "test_issue_66_3" -> "T & C"and got the following results:
<string name="test_issue_66_1">"T&C"</string> <string name="test_issue_66_2">"T & C"</string> <string name="test_issue_66_3">"T &amp; C"</string>These should be the proper escape sequences so I believe the plugin is working as expected. Does the error happen when using the plugin or when compiling your apps?
— Reply to this email directly, view it on GitHub https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/issues/66#issuecomment-1695973837, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6R4EU6PDW745GNBBQOMFLXXTAELANCNFSM6AAAAAAYGFBWWE . You are receiving this because you were mentioned.Message ID: @.*** .com>
We've had the same issue in one of our own projects.
PoEditor CMS contains the following string:
When using this config (which doesn't specify the unescapeHtmlTags field), we get the error:
poEditor {
apiToken.set("xxx")
projectId.set(123)
order.set("terms")
tags.set(listOf("android", "app"))
unquoted.set(true)
}
However, when turning unescapeHtmlTags to false, it works without any issues:
poEditor {
apiToken.set("xxx")
projectId.set(123)
order.set("terms")
tags.set(listOf("android", "app"))
unquoted.set(true)
unescapeHtmlTags.set(false)
}
<string name="puf_details_solutions">Common problems & solutions</string>
This happens because the default value of unescapeHtmlTags is true. It seems rather confusing that we need to toggle the default value of the unescapeHtmlTags field in order to affect ampersand parsing, as it should work regardless of this config value.
This started happening in our project when we updated: from AGP 4.2.2 + gradle 6.9 + java 8 to AGP 8.3.0 + gradle 8.4 + java 17 (build), java 11 (source)
It happens both with plugin version 3.4.2 and 4.2.0.
Caused by: org.xml.sax.SAXParseException; lineNumber: 1601; columnNumber: 59; The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
at com.hyperdevs.poeditor.gradle.ktx.DocumentExtensionsKt.toStringsXmlDocument(DocumentExtensions.kt:41)
at com.hyperdevs.poeditor.gradle.xml.XmlPostProcessor.splitTranslationXml(XmlPostProcessor.kt:113)
at com.hyperdevs.poeditor.gradle.xml.XmlPostProcessor.postProcessTranslationXml(XmlPostProcessor.kt:55)
at com.hyperdevs.poeditor.gradle.PoEditorStringsImporter.importPoEditorStrings(PoEditorStringsImporter.kt:146)
at com.hyperdevs.poeditor.gradle.tasks.ImportPoEditorStringsTask.importPoEditorStrings(ImportPoEditorStringsTask.kt:184)
Nice that unescapeHtmlTags = false fixes the issue. It introduces some other changes though. Some seem fine, some can be problematic.
This seems fine - it changes emoji codes/formats, but they still work.
For instance, it changes this string 🤩 into 🤩. Both resolve to the same emoji - 🤩. The first one is the emoji Hex code point (as it was originally, before upgrading AGP, gradle and Java). The second one is the Decimal code point of the same emoji.
This does not seem fine though - it encodes tags, so they don't work anymore. For instance, it breaks tags like <b>. You might be using this tag to make text bold in the Android UI (works even in Toast messages). For instance:
John is \"<b>awesome</b>\", really! will output "John is "awesome", really!"
But it will be broken when using unescapeHtmlTags = false. The translation is saved this way:
John is \"<b>awesome</b>\", really!
Which appears like this in the UI (it doesn't pick up the tags):
John is \"<b>awesome</b>\", really!
Having the same exact issue.
Plugin version: 4.2.0
The term in POEditor is:
Enable Alarm & Reminders - issue reproduces, gradle task fails
Enable Alarm & Reminders - task succeeds, the result is "Enable Alarm & Reminders" (& breaks Android strings in that case)
Enable Alarm &amp; Reminders- task succeeds, produces correct Android string: "Enable Alarm & Reminders"