Skip to content
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

Tolgee doesn't parse ruby yaml correctly for some cases #2574

Closed
cccccroge opened this issue Oct 11, 2024 · 5 comments · Fixed by #2629
Closed

Tolgee doesn't parse ruby yaml correctly for some cases #2574

cccccroge opened this issue Oct 11, 2024 · 5 comments · Fixed by #2629
Assignees

Comments

@cccccroge
Copy link

cccccroge commented Oct 11, 2024

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

Additional context
Add any other context about the problem here.

@Anty0
Copy link
Collaborator

Anty0 commented Oct 11, 2024

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
Copy link
Collaborator

Anty0 commented Oct 11, 2024

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

@Anty0 Anty0 closed this as completed Oct 11, 2024
@cccccroge
Copy link
Author

cccccroge commented Oct 11, 2024

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

@Anty0
Copy link
Collaborator

Anty0 commented Oct 14, 2024

Interesting. I'll try to reproduce it locally.

@Anty0
Copy link
Collaborator

Anty0 commented Oct 25, 2024

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

TolgeeMachine pushed a commit that referenced this issue Oct 29, 2024
## [3.80.5](v3.80.4...v3.80.5) (2024-10-29)

### Bug Fixes

* Avoid requesting super auth when authentication is disabled ([#2630](#2630)) ([3f7919a](3f7919a))
* Respect project.icuPlaceholders in singleStepImport ([#2629](#2629)) ([5e2b72a](5e2b72a)), closes [#2574](#2574)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants