Originally posted by **dvolkovv** September 19, 2024
Hello, I am working on an Android project consisting of many modules that have strings files inside them.
I wrote a small gradle plugin that accesses the Tolgee service, exports translations by module path and puts them in the /res/values folder of the module
The problem arises when I need to export a lot of strings from different modules. Tolgee sometimes returns a string file in which the line feed for one or two instances is not escaped, other strings might contain normal newline '\n' character.
This does not always occur and not for all files, which is very strange. After completing the gradle task, it can return correctly encoded strings, and everything is fine.
I need the files not to differ when exporting, because I also configured a gradle task that compares the exported strings from Tolgee and those in the module, and crashes if they do not match. This helps me keep up-to-date translations in Tolgee and rely on the service rather than local strings.
I am using self-hosted Tolgee version 3.73.0
To reproduce:
Have an android project of ~50 (or more) modules
Have a gradle plugin that uses the Tolgee REST API to export string resources
Have some strings in Tolgee configured as such
Execute gradle task to export strings for these ~50 modules, store those strings and check them
Actual behavior:
Some of the downloaded strings files might have line feed instead of \n character. Subsequent calls to export strings for that module might export suitable strings with valid newline characters.
Expected behavior:
Strings identical between exports from Tolgee. \n symbols as new line symbols in string.
Details:
I have gradle plugin that adds task that exports strings from Tolgee by module name. Requests to Tolgee performed this way:
//This code inside abstract static class UpdateTranslations extends DefaultTask
String query = "?format=ANDROID_XML&filterNamespace=$path"
HttpURLConnection req = null
InputStream input
try {
req = (HttpURLConnection) new URL("$ENDPOINT$query").openConnection()
req.setRequestProperty("X-API-Key", API_KEY)
input = req.inputStream
} catch (IOException ignored) { //not found translations for module handling }
//Next there is code that unzips archive that comes from Tolgee, and stores strings in res directory
//I've checked that new line symbols was already in strings in archive, not that they added after archive extraction
Then, i'm using command gradlew updateTranslations from project root, which leads to updateTranslations executed in every subproject.
After execution, in vcs i see that some files might have line feed instead of \n.
Subsequent call might fix that line feed in those files and put valid \n in those places. Then it might appear again and so on.
Texts configured in Tolgee identically, without adding \n, only by using manual ctrl+enter to switch to another line.
Hello, created an issue after discussion in Q&A section.
Discussed in https://github.com/tolgee/tolgee-platform/discussions/2473
To reproduce:
Have an android project of ~50 (or more) modules
Have a gradle plugin that uses the Tolgee REST API to export string resources
Have some strings in Tolgee configured as such
Execute gradle task to export strings for these ~50 modules, store those strings and check them
Actual behavior: Some of the downloaded strings files might have line feed instead of \n character. Subsequent calls to export strings for that module might export suitable strings with valid newline characters.
Expected behavior: Strings identical between exports from Tolgee. \n symbols as new line symbols in string.
Details: I have gradle plugin that adds task that exports strings from Tolgee by module name. Requests to Tolgee performed this way:
Then, i'm using command
gradlew updateTranslations
from project root, which leads toupdateTranslations
executed in every subproject. After execution, in vcs i see that some files might have line feed instead of \n.Subsequent call might fix that line feed in those files and put valid \n in those places. Then it might appear again and so on.
Texts configured in Tolgee identically, without adding \n, only by using manual ctrl+enter to switch to another line.