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

Bug with nested jsons #345

Closed
Yalian opened this issue Jul 7, 2020 · 7 comments
Closed

Bug with nested jsons #345

Yalian opened this issue Jul 7, 2020 · 7 comments
Labels
bug Something isn't working needs reproduction

Comments

@Yalian
Copy link

Yalian commented Jul 7, 2020

Describe the bug
when you have the translations in nested json, and you want to translate from the code, and the key is for example "example.user" instead of putting it as an object in the json, it puts it exactly the same as "example.user": ""

Extension Version

  • i18n Ally 2.2.7

Framework/i18n package you are using

  • react-i18next

To Reproduce

  1. create a json with nested translations
  2. put a translation in the code that should be nested ex: "example.user"
  3. put any translation and in the file you will find the key exactly as it is written instead of being in an ex: "example": {"user": ""} "

Device Infomation

  • OS: Ubuntu
  • Version: 19.04
  • VS Code Version: 1.46.1

Extension Log
Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information


🧰 Config "i18n-ally.enabledParsers" changed, reloading
🔁 Reloading loader
🧩 Enabled frameworks: i18next
🧬 Enabled parsers: json

🚀 Initializing loader "/home/lawrence/apps/frontend-react"
📂 Directory structure: dir
🗃 Custom Path Matcher: {locale}/translation.json
🗃 Path Matcher Regex: /^(?<locale>[\w-_]+)\/translation\.json$/

📂 Loading locales under /home/lawrence/apps/frontend-react/src/locales
	📑 Loading (en) en/translation.json [1594085693895.4465]
	📑 Loading (es) es/translation.json [1594086180291.0793]

👀 Watching change on /home/lawrence/apps/frontend-react/src/locales
✅ Loading finished


――――――

🔄 File changed (change) es/translation.json
	📑 Loading (es) es/translation.json [1594086471940.9163]

Screenshots
Peek 2020-07-06 21-05

@Yalian Yalian added the bug Something isn't working label Jul 7, 2020
@antfu
Copy link
Contributor

antfu commented Jul 7, 2020

May I have your config?

@Yalian
Copy link
Author

Yalian commented Jul 7, 2020

May I have your config?

  "i18n-ally.sortKeys": true,
  "i18n-ally.translate.overrideExisting": true,
  "i18n-ally.keystyle": "nested",
  "i18n-ally.pathMatcher": "{locale}/translation.json",

@antfu
Copy link
Contributor

antfu commented Jul 9, 2020

I am seeing no problem with the example https://github.com/antfu/i18n-ally/tree/master/examples/by-frameworks/react%2Bi18next

Can you share me a minimal reproduce repo? Thanks

@Trunksome
Copy link

I experience the same issue. Everything seems to be fine, all translations are detected and shown in the editor. Then I attempt to update a translation from within the editor, and after accepting the change via "enter", it appends a non-nested string to the end of the json file and from now on does not detect any nested translation correctly. What am I missing?

"i18n-ally.keystyle": "nested",
"i18n-ally.localeCountryMap": {}

@Yalian Yalian closed this as completed Aug 31, 2020
@andyweber-bamf
Copy link

Having exact same issue as originally described, same steps to reproduce. Framework is vue-i18n.

@Yalian Did you find a solution?

@grupofantec
Copy link

grupofantec commented Oct 3, 2020

Having exact same issue as originally described, same steps to reproduce. Framework is vue-i18n.

@Yalian Did you find a solution?

no :s,I ended up stopping using the tool, and used traduora for the translations and it serves me for multiple projects

@pasindu-pr
Copy link

I experience the same issue. Everything seems to be fine, all translations are detected and shown in the editor. Then I attempt to update a translation from within the editor, and after accepting the change via "enter", it appends a non-nested string to the end of the json file and from now on does not detect any nested translation correctly. What am I missing?

"i18n-ally.keystyle": "nested", "i18n-ally.localeCountryMap": {}

I also faced this same issue today. But when I change the key style both in user and workspace settings in Vscode it was solved. Initially, I only changed this setting in user settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction
Development

No branches or pull requests

6 participants