tolgee-platform icon indicating copy to clipboard operation
tolgee-platform copied to clipboard

Tolgee doesn't parse ruby yaml correctly for some cases

Open cccccroge opened this issue 1 year ago • 4 comments

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:

  1. upload key: value 'value' to tolgee result in value 'value'' (there's an extra single quote in the end)
  2. upload key: value'%{variable}' to tolgee result in value''<variable>'' (there are two single quotes around variable, which should be one)
  3. upload key: value{{variable}}value to tolgee result in value'{{'variable'}}'value (two single quotes around {{ and }} shouldn't exist)
  4. 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:

  1. 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
  }
}
  1. 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
  1. Go to translations page in tolgee host
  2. It shows unexpected result e.g. image

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.

cccccroge avatar Oct 11 '24 10:10 cccccroge

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.

Anty0 avatar Oct 11 '24 11:10 Anty0

@cccccroge Feel free to reopen the issue if there is something I've missed.

Anty0 avatar Oct 11 '24 11:10 Anty0

@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?

cccccroge avatar Oct 11 '24 15:10 cccccroge

Interesting. I'll try to reproduce it locally.

Anty0 avatar Oct 14 '24 07:10 Anty0

@cccccroge Thank you for the clarification! I was able to reproduce the issue, and it should be fixed once #2629 gets released.

Anty0 avatar Oct 25 '24 13:10 Anty0