Tolgee doesn't parse ruby yaml correctly for some cases
Describe the bug
In our Rails project, some of the values result in extra single quote (') when I check on Tolgee admin.
Here's the cases we found:
- upload
key: value 'value'to tolgee result invalue 'value''(there's an extra single quote in the end) - upload
key: value'%{variable}'to tolgee result invalue''<variable>''(there are two single quotes around variable, which should be one) - upload
key: value{{variable}}valueto tolgee result invalue'{{'variable'}}'value(two single quotes around {{ and }} shouldn't exist) - upload
key: "{variable} value"to tolgee result in'{'file'}' value(two single quotes around { and } shouldn't exist)
To Reproduce Steps to reproduce the behavior:
- Create tolgee config that use Ruby format:
{
"$schema": "https://tolgee.io/cli-schema.json",
"format": "YAML_RUBY",
"push": {
"files": [
// these files should contain the patterns mentioned above
],
"forceMode": "OVERRIDE",
"convertPlaceholdersToIcu": false
}
}
- Push to the target url
npx @tolgee/[email protected] push \
--config ./test.tolgeerc.json \
--api-url ${TOLGEE_INSTANCE_URL} \
--api-key ${TOLGEE_PERSONAL_ACCESS_KEY} \
--project-id ${TOLGEE_PROJECT_ID_RAILS} \
--verbose
- Go to translations page in tolgee host
- It shows unexpected result
e.g.
Expected behavior
I expect tolgee don't transform value that is not interpolated string (%{xxx}) as they are valid yaml values. e.g. single quote (') and curly braces ({, }, {{, }}) should not be escaped.
Screenshots see above
Versions and environment
- Tolgee Platform version: 3.68.2
- Environment: local docker (https://hub.docker.com/layers/tolgee/tolgee/v3.68.2/images/sha256-cd8a247cba511ed846cbc51a36b221c24b69a18b32cae63ed3db36f3a3e87a06?context=explore)
- Browser: not relevant
Additional context Add any other context about the problem here.
Hi! Thank you for the report.
When importing translations to tolgee, all strings are converted to ICU format by default (can be disabled). As part of this conversion, all characters with a special meaning in the ICU format have to be escaped, which is what you see now. You can read more here.
You can try to export your translations immediately after importing them. The resulting exported file should look the same as the imported one since all your strings will be converted to the selected format.
When needed, you can disable ICU conversion for the whole project (more info here), but this will also disable support for variables and other ICU features for that project.
@cccccroge Feel free to reopen the issue if there is something I've missed.
@cccccroge Feel free to reopen the issue if there is something I've missed.
@Anty0
Well I think the problem still exist even when I disable ICU conversion both "globally"(in project setting) and "locally"(set convertPlaceholdersToIcu to false in config file).
But after I disable the ICU conversion, when I import via interface it works! And the problem occur when I use cli (see step 2. in the issue description for detail command). Could you check on cli?
Interesting. I'll try to reproduce it locally.
@cccccroge Thank you for the clarification! I was able to reproduce the issue, and it should be fixed once #2629 gets released.