question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[vite] Error if using HTML tags inside a file referenced by SFC block "src" attribute

See original GitHub issue

Reporting a bug?

Hi, I stumbled upon a weird problem. I have localizations that contain HTML tags and it worked fine while the text was specified inside of <i18n> SFC tag, but later I started switching to <i18n src="path/to/file.yaml> style for easier translation handling and the plugin now doesn’t generate the locales. And I narrowed down the cause to whether or not the file has anything resembling an HTML tag e.g. text <string> text

Expected behavior

It shouldn’t fail

Reproduction

This works fine:

<i18n lang="yaml">
en:
  test: message <span>test</span> text
</i18n>

While this fails:

<i18n lang="yaml" src="file.yaml"></i18n>

file.yaml:

en:
  test: message <span>test</span> text

Issue Package

vite-plugin-vue-i18n

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 1.30 GB / 7.82 GB
  Binaries:
    Node: 16.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.15.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 102.0.5005.63
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.53)
  npmPackages:
    @intlify/vite-plugin-vue-i18n: ^4.0.0 => 4.0.0
    vite: ^2.9.9 => 2.9.9
    vue: ^3.2.25 => 3.2.36
    vue-i18n: 9@beta => 9.2.0-beta.35

Screenshot

No response

Additional context

This issue can be currently avoided by using literal interpolation: {'<'} and {'>'}

Validations

  • Read the Contributing Guidelines.
  • Read the README
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kazuponcommented, Jun 6, 2022

Thank you for your reproduction repo! I’ll check your repo.

0reactions
ssuesscommented, Aug 8, 2022

Is there any movement on this? For now, I have had to change every instance that contains html from something like this: <i18n src="../i18n-compiled/myfile.json"></i18n> to <i18n>{"en-GB":{"description":"<p>Some <em>HTML</em> stuff</p>"}}</i18n> which completley screws up our ability to feed in translations from our outside system automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin API - Vite
It allows you to inspect the intermediate state of Vite plugins. After installing, you can visit localhost:5173/__inspect/ to inspect the modules and ...
Read more >
<script setup> | Vue.js
<script setup> is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs). It is the recommended syntax if you are ......
Read more >
Single file components | Vue I18n - Intlify
In the above example, src attribute is set to ./myLang.json , so the path of the component with the i18n custom blocks is...
Read more >
How To Navigate Between Views with Vue Router
js file and inject the mounted component where <router-view /> is referenced. To do this, you need to reference it in the src/main.js...
Read more >
Building Web Components with Vue 3.2 - This Dot Labs
Web Components allow developers to build their own elements, and reference them in their HTML - no framework required.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found