nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.74k stars 483 forks source link

Invalid linked format|Unexpected lexical analysis in token: '#$^*?_(). `V8-Nuxt3` #2116

Closed waleedtariq109 closed 1 year ago

waleedtariq109 commented 1 year ago

Environment

Operating System: Ubuntu Node Version: 18.16.0 Npm Version: 9.5.1 Nuxt Version: 3.5.1

Reproduction

Link to reproduction

Describe the bug

When I run the npm run dev command, it throws an error message like Invalid linked format|Unexpected lexical analysis in token. After that, I navigate to my ar-SA.json locale file and remove all the JSON code, leaving only one key-value pair like this:

{
   "hello": "World"
}

and I save the locale file, then I paste the previous JSON code, save it, and reload the project. After that, everything is working fine.

Additional context

I have to remove all the JSON code from the locale file, then add only one property with a random name and value, and save the file. After that, I paste the previous code and save the file again. Everything works fine at that point. However, if I close the server and restart it, I encounter the same issue again. I have to follow the same steps in order to resolve this error.

Logs

(400 Invalid linked format|Unexpected lexical analysis in token: '#$^*?_().'|Unexpected empty linked key|Invalid linked format|Unexpected lexical analysis in token: '#?.,:;_-'|Unexpected empty linked key (/__i18n__/precompile))

at async __vite_ssr_exports__.default (./@nuxtjs/i18n/__config__:16:23)
at async vueI18nConfigLoader (./.nuxt/i18n.options.mjs:20:19)
at async Module.resolveNuxtI18nOptions (./.nuxt/i18n.options.mjs:23:19)
at async Object.setup (./node_modules/@nuxtjs/i18n/dist/runtime/plugins/i18n.mjs:22:154)
at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)
at async applyPlugin (./node_modules/nuxt/dist/app/nuxt.js:111:23)
at async Module.applyPlugins (./node_modules/nuxt/dist/app/nuxt.js:127:7)
at async createNuxtAppServer (./node_modules/nuxt/dist/app/entry.js:29:7)
at async default (./node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:31:18)
kazupon commented 1 year ago

Thank you for your feedback.

I noticed that your code has some special characters on your resources.

"passwordDoesNotContainSpecialCharacters": "يجب أن تحتوي كلمة المرور على رمز مثل: (!,%&@#$^*?_().:;-).",

You need to use literal interpolation for special characters. https://vue-i18n.intlify.dev/guide/essentials/syntax.html#special-characters

waleedtariq109 commented 1 year ago

@kazupon Thanks now it works

Soviut commented 10 months ago

For posterity, I wanted to display a placeholder in an email field:

emailPlaceholder: 'eg: test@example.com'

However, it complained about the @ symbol.

I needed to put the entire string inside literal:

emailPlaceholder: "{'eg: test@example.com'}"
carbdias commented 9 months ago

Are the quotes in the above example correct ? I still get the warning in the same translation ..

I'm trying this approach instead

https://vue-i18n.intlify.dev/guide/essentials/syntax#named-interpolation

davefrassoni commented 1 week ago

for html, just use this method: "some-key": "{' your html translated text <a href=\"mailto:hello@mail.com\"> more text '}"