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

Vue Projects: File Format Matters #1220

Open
tieniu1 opened this issue Oct 16, 2024 · 0 comments
Open

Vue Projects: File Format Matters #1220

tieniu1 opened this issue Oct 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tieniu1
Copy link

tieniu1 commented Oct 16, 2024

Recently, I encountered some problems while using i18n-ally for internationalization in Vue projects. I'm sharing my experience here, hoping it might help other developers facing similar issues.

Problems Encountered

  1. In a Vue 2 project created with Vue CLI, language files (src/lang/zh.js and en.js) loaded normally.
  2. In a Vue 3 project created with Vite, language files failed to load with the same configuration.
  3. The problem was resolved after changing the language files to JSON format.
  4. In VSCode, i18n variables don't display their actual values.
  5. Using Chinese as i18n keys in the Vue 2 project led to more issues.

Key Finding

Strongly recommend using JSON format for language files. This can avoid many potential loading problems.
Current i18n-ally Configuration

"i18n-ally.displayLanguage": "zh-CN",
"i18n-ally.keystyle": "nested",
"i18n-ally.enabledFrameworks": ["vue"],
"i18n-ally.enabledParsers": ["js", "json"],
"i18n-ally.localesPaths": [
  "src/i18n/lang",
],

Use JSON format for language files.

  1. Avoid using Chinese as i18n keys; use English or other easily identifiable identifiers instead.
  2. Be aware of potential configuration differences between Vue 2 and Vue 3 projects.
  3. If anyone has encountered similar issues or has better solutions, please feel free to share.

image

@tieniu1 tieniu1 added the bug Something isn't working label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant