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

mergeLocaleMessage in petite 18n broken after 9.6.0 - converts to nested object by itself #1717

Closed
4 tasks done
chojnicki opened this issue Jan 29, 2024 · 0 comments · Fixed by #1718
Closed
4 tasks done
Labels
Status: Review Needed Request for review comments

Comments

@chojnicki
Copy link
Contributor

Reporting a bug?

After upgrading petite-vue-i18n from 9.5.0 translations on app broke (messages not found).

I'm using simple key, not nested objects (by default in petite).

Screenshot from 2024-01-29 19-40-26

Translations are lazy loaded from .json files and merged.

const messages = await import(`./locales/${category}/${locale}.json`)
i18n.global.mergeLocaleMessage(locale, messages.default)

I debugged it via i18n.global.getLocaleMessage('pl') and noticed that my translations are nested, WTF :D

Screenshot from 2024-01-29 19-36-28

By downgrading version after version I discovered that issue is with 9.6.0, and noticed noticed this commit in changelog:
edaf498

Using flatConfig in i18n config does not help, and I guess should not be used in petite anyway.

I've commented this line in petite-vue-i18n dist source:

handleFlatJson(_message[key]);

and it works.

Then I noticed that in setLocaleMessage there is condition

if (flatJson) {

for that handleFlatJson, but it's missing in mergeLocaleMessage. Why? After adding this, again everything works. Was this on purpose? I case this is a typo, I will provide pull request. If not - @kazupon please provide other solution :(

Expected behavior

Keys like 'a.b.c' should be treated like strings, not transformed into object.

Reproduction

Described above.

System Info

Described above.

Screenshot

No response

Additional context

No response

Validations

@chojnicki chojnicki added the Status: Review Needed Request for review comments label Jan 29, 2024
chojnicki added a commit to chojnicki/vue-i18n-next that referenced this issue Jan 29, 2024
chojnicki added a commit to chojnicki/vue-i18n-next that referenced this issue Jan 30, 2024
kazupon pushed a commit that referenced this issue Jan 31, 2024
* fix: key-value style messages broken after merging (#1717)

* test: missing test for pull request #1718 (issue #1717)
Blankll added a commit to geek-fun/dockit that referenced this issue May 26, 2024
<p>This PR was automatically created by Snyk using the credentials of a
real user.</p><br /><h3>Snyk has created this PR to upgrade vue-i18n
from 9.9.1 to 9.10.1.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.
<hr/>

- The recommended version is **2 versions** ahead of your current
version.
- The recommended version was released **24 days ago**, on 2024-03-01.


<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>vue-i18n</b></summary>
    <ul>
      <li>
<b>9.10.1</b> - <a
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/releases/tag/v9.10.1">2024-03-01</a></br>
<h2>What's Changed</h2>
<h3>⚡ Improvement Features</h3>
<ul>
<li>chore(fix): <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="1977884644"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1630"
data-hovercard-type="issue"
data-hovercard-url="/intlify/vue-i18n/issues/1630/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/issues/1630">#1630</a>
make the install function synchronous to be aligned… by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/k-paxian/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/k-paxian">@ k-paxian</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="1977894436" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1631"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1631/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1631">#1631</a></li>
</ul>
<h3>📝️ Documentations</h3>
<ul>
<li>docs: wrong te docs by <a class="user-mention notranslate"
data-hovercard-type="user" data-hovercard-url="/users/kazupon/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/kazupon">@ kazupon</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2162382013" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1753"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1753/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1753">#1753</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/k-paxian/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/k-paxian">@ k-paxian</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="1977894436"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1631"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1631/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1631">#1631</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/compare/v9.10.0...v9.10.1"><tt>v9.10.0...v9.10.1</tt></a></p>
      </li>
      <li>
<b>9.10.0</b> - <a
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/releases/tag/v9.10.0">2024-03-01</a></br>
<h2>What's Changed</h2>
<h3>🌟 Features</h3>
<ul>
<li>fix: Support for <code>te</code> behavior compatibility before v9.6
by <a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/kazupon/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/kazupon">@ kazupon</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2161629313" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1751"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1751/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1751">#1751</a></li>
</ul>
<h3>📝️ Documentations</h3>
<ul>
<li>docs: update description of Nuxt I18n and its status by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/BobbieGoede/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/BobbieGoede">@ BobbieGoede</a> in
<a class="issue-link js-issue-link" data-error-text="Failed to load
title" data-id="2134440982" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1739"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1739/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1739">#1739</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/twolfvb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/twolfvb">@ twolfvb</a> made their
first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="2127293242"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1732"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1732/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1732">#1732</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/ismailarilik/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/ismailarilik">@ ismailarilik</a>
made their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="2112407750"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1722"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1722/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1722">#1722</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/compare/v9.9.1...v9.10.0"><tt>v9.9.1...v9.10.0</tt></a></p>
      </li>
      <li>
<b>9.9.1</b> - <a
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/releases/tag/v9.9.1">2024-01-31</a></br>
<h2>What's Changed</h2>
<h3>🐛 Bug Fixes</h3>
<ul>
<li>fix: key-value style messages broken after merging (<a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2106337998" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1717"
data-hovercard-type="issue"
data-hovercard-url="/intlify/vue-i18n/issues/1717/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/issues/1717">#1717</a>)
by <a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/chojnicki/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/chojnicki">@ chojnicki</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2106359675" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1718"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1718/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1718">#1718</a></li>
</ul>
<h3>📝️ Documentations</h3>
<ul>
<li>chore(typo): update injection.md by <a class="user-mention
notranslate" data-hovercard-type="user"
data-hovercard-url="/users/quentinmcq/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/quentinmcq">@ quentinmcq</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2106214510" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1716"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1716/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1716">#1716</a></li>
<li>Update syntax.md by <a class="user-mention notranslate"
data-hovercard-type="user" data-hovercard-url="/users/hinogi/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/hinogi">@ hinogi</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2084038770" data-permission-text="Title is private"
data-url="intlify/vue-i18n#1701"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1701/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1701">#1701</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/chojnicki/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/chojnicki">@ chojnicki</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="2106359675"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1718"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1718/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1718">#1718</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/quentinmcq/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/quentinmcq">@ quentinmcq</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="2106214510"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1716"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1716/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1716">#1716</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/hinogi/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://snyk.io/redirect/github/hinogi">@ hinogi</a> made their
first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="2084038770"
data-permission-text="Title is private"
data-url="intlify/vue-i18n#1701"
data-hovercard-type="pull_request"
data-hovercard-url="/intlify/vue-i18n/pull/1701/hovercard"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/pull/1701">#1701</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/compare/v9.9.0...v9.9.1"><tt>v9.9.0...v9.9.1</tt></a></p>
      </li>
    </ul>
from <a
href="https://snyk.io/redirect/github/intlify/vue-i18n-next/releases">vue-i18n
GitHub release notes</a>
  </details>
</details>
<hr/>

**Note:** *You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs.*

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiJjYTFlODQ3MC00NzBhLTQ4NDktYWQxMi02YzJiZDg3ZGRjOGYiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6ImNhMWU4NDcwLTQ3MGEtNDg0OS1hZDEyLTZjMmJkODdkZGM4ZiJ9fQ=="
width="0" height="0"/>

🧐 [View latest project
report](https://app.snyk.io/org/blankll/project/d19c39b4-9b25-4232-b09a-2d71e94c8a24?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/blankll/project/d19c39b4-9b25-4232-b09a-2d71e94c8a24/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/blankll/project/d19c39b4-9b25-4232-b09a-2d71e94c8a24/settings/integration?pkg&#x3D;vue-i18n&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

<!---
(snyk:metadata:{"prId":"ca1e8470-470a-4849-ad12-6c2bd87ddc8f","prPublicId":"ca1e8470-470a-4849-ad12-6c2bd87ddc8f","dependencies":[{"name":"vue-i18n","from":"9.9.1","to":"9.10.1"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/blankll/project/d19c39b4-9b25-4232-b09a-2d71e94c8a24?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"d19c39b4-9b25-4232-b09a-2d71e94c8a24","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":2,"publishedDate":"2024-03-01T01:30:48.317Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]})
--->

Co-authored-by: snyk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant