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

Issue when using variables in translations #43

Open
eertmanhidde opened this issue Jun 25, 2024 · 1 comment
Open

Issue when using variables in translations #43

eertmanhidde opened this issue Jun 25, 2024 · 1 comment

Comments

@eertmanhidde
Copy link

First of all, thanks very much for this package 🙌🏻

What is the issue?

We're having translation issues when trying to translate the following

{
  "withCount": {
    "nl": "Nederlands ({{ count }})",
    "en": "English ({{ count }})",
    "zh": "中文 ({{ count }})",
    "fr": "Français ({{ count }})",
    "de": "Deutsch ({{ count }})",
    "es": "Español ({{ count }})",
    "pl": "Polski ({{ count }})",
    "ru": "Pусский ({{ count }})",
    "cs": "Česky ({{ count }})"
  }
}

This results in 2 issues for us, when translating to Czech we get for example this "cs": "Česky (8)",
and in Dutch we get this

    "pl": "Polski ({{{ count }})",
    "ru": "Pусский ({{ count }}",
    "cs": "Česky ({{{ count }})"

Notes

  • I saw somewhere that something like {|} is used as the delimiter, so using "cs": "Česky ([ count ])" works fine, but sadly we need to use {{ VAR }} for variables.
  • We're using Deepl
  • I haven't tried yet with other providers
  • I checked some other closed issues but couldn't really find something related to this

Perhaps we're doing something wrong?

Again, thanks for the library!

@while1618
Copy link
Owner

Hi @eertmanhidde,

I think that the main problem here is that you are mixing languages in one json file, and then deepl doesn't know from which language to translate.

I added some logs to test your case, and also I faced the same problems, parentheses are missing, or they are added where they don't belong, but that was a response from deepl, not something that I did in my code to change it, that's why I think that you confused deepl with more than one language.

I have tried to change json file, so that it's all in English, and that worked without problems.

Also, I tested your original json file with other providers, and there it worked without "parentheses problem", but again, this is purely deepl response, and there is not much I can do about it.

You are not the only one with deepl problems, you can check this issue #39. I was finally able to get deepl key, and made some tests, so I decided to change delimiter, and issue #39 seems to be fixed now. Fix will be released in v1.5.0 soon.

Some things you can do for your case, think about changing the structure of your json file to not mix languages, or if that's not possible, try with other provides. Once I release v1.5.0, deepl should work as expected, and you won't face some wired bugs because of delimiter. At least that's the case with data I used for testing. But the problem with parentheses in json you provided is still there, and I think there is not much from my side I can do to fix it.

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

No branches or pull requests

2 participants