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

Parsing multiple strings in HTML #409

Closed
julienmiclo opened this issue Mar 26, 2021 · 5 comments · Fixed by #411
Closed

Parsing multiple strings in HTML #409

julienmiclo opened this issue Mar 26, 2021 · 5 comments · Fixed by #411
Labels
Status: Proposal Request for comments

Comments

@julienmiclo
Copy link

Hello,
i read documentation and search in issues but i didn't find an answer for my question. It's possible to parse array of multiple strings before rendering like this :

  cgv: {
    contents: [
      {
        title: "Titre #1",
        paragraphs: [
            "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
            "In sollicitudin dui in placerat vehicula. Praesent ante mi, imperdiet sed lectus sed, pretium efficitur risus. Aenean at enim a enim consectetur consectetur vitae sit amet orci.",
            "Donec vulputate imperdiet neque sit amet imperdiet. Nulla in justo vitae diam tincidunt pellentesque vitae ut metus. Donec vel sapien a elit hendrerit lacinia eu a nibh. Etiam tempus mauris venenatis suscipit venenatis."
        ]
      },
{
        title: "Titre #2",
        paragraphs: [
            "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
            "In sollicitudin dui in placerat vehicula. Praesent ante mi, imperdiet sed lectus sed, pretium efficitur risus. Aenean at enim a enim consectetur consectetur vitae sit amet orci.",
        ]
      }
    ]
  }

result :

<h2>Titre #1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>In sollicitudin dui in placerat vehicula. Praesent ante mi, imperdiet sed lectus sed, pretium efficitur risus. Aenean at enim a enim consectetur consectetur vitae sit amet orci.</p>
<p>Donec vulputate imperdiet neque sit amet imperdiet. Nulla in justo vitae diam tincidunt pellentesque vitae ut metus. Donec vel sapien a elit hendrerit lacinia eu a nibh. Etiam tempus mauris venenatis suscipit venenatis.</p>

Thank you !

@kazupon
Copy link
Member

kazupon commented Mar 27, 2021

Thank you for your feedback!

If you want to handle an array-like cgv.contents, you need to use tm.

<template v-for="content in tm('cvg.contents')">
  <h2>{{ content.title }}</h2>
  <p v-for="paragraph in content.paragraphs">
    {{ paragraph }}
  </p>
</template>

tm will return a reactive value. If you change the locale, tm will reactively return the value corresponding to the locale.

@kazupon
Copy link
Member

kazupon commented Mar 27, 2021

However, I realized that this does not work when I pre-compile i18n resources. i18n resources pre-compile compiles all locale messages as message functions.

The message function needs to be run through the vue-i18n runtime. These message functions cannot be executed directly. It needs to be extending t or add a new API.

I will try to fix this issue.

@kazupon kazupon added the Status: Proposal Request for comments label Mar 27, 2021
kazupon added a commit that referenced this issue Mar 28, 2021
kazupon added a commit that referenced this issue Mar 28, 2021
* feat: resolve locale message translation (rt)

closes #409

* update docs

* fix typo
@kazupon
Copy link
Member

kazupon commented Mar 28, 2021

I've just fixed!
I've added new API rt ($rt).
This fix will be available after the release of v9.1.

@julienmiclo
Copy link
Author

Merci !

@julienmiclo
Copy link
Author

@kazupon have you a date for release of v9.1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants