-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
fix: rename locale iso
property to language
#3055
fix: rename locale iso
property to language
#3055
Conversation
specs/basic_usage.spec.ts
Outdated
@@ -141,7 +141,7 @@ describe('basic usage', async () => { | |||
) | |||
|
|||
expect(await getText(page, '#locale-head')).toMatchInlineSnapshot( | |||
`"{ "htmlAttrs": { "lang": "en" }, "link": [ { "hid": "i18n-alt-en", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "en" }, { "hid": "i18n-alt-fr", "rel": "alternate", "href": "/fr/nuxt-context-extension", "hreflang": "fr" }, { "hid": "i18n-alt-ja", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja" }, { "hid": "i18n-alt-ja-JP", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "hid": "i18n-alt-nl", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl" }, { "hid": "i18n-alt-nl-NL", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "hid": "i18n-alt-kr", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr" }, { "hid": "i18n-alt-kr-KO", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "hid": "i18n-xd", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "x-default" }, { "hid": "i18n-can", "rel": "canonical", "href": "/nuxt-context-extension" } ], "meta": [ { "hid": "i18n-og-url", "property": "og:url", "content": "/nuxt-context-extension" }, { "hid": "i18n-og", "property": "og:locale", "content": "en" }, { "hid": "i18n-og-alt-fr", "property": "og:locale:alternate", "content": "fr" }, { "hid": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "hid": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "hid": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"` | |||
`"{ "htmlAttrs": { "lang": "en" }, "link": [ { "hid": "i18n-alt-en", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "en" }, { "hid": "i18n-alt-fr", "rel": "alternate", "href": "/fr/nuxt-context-extension", "hreflang": "fr" }, { "hid": "i18n-alt-fr-FR", "rel": "alternate", "href": "/fr/nuxt-context-extension", "hreflang": "fr-FR" }, { "hid": "i18n-alt-ja", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja" }, { "hid": "i18n-alt-ja-JP", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "hid": "i18n-alt-nl", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl" }, { "hid": "i18n-alt-nl-NL", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "hid": "i18n-alt-kr", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr" }, { "hid": "i18n-alt-kr-KO", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "hid": "i18n-xd", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "x-default" }, { "hid": "i18n-can", "rel": "canonical", "href": "/nuxt-context-extension" } ], "meta": [ { "hid": "i18n-og-url", "property": "og:url", "content": "/nuxt-context-extension" }, { "hid": "i18n-og", "property": "og:locale", "content": "en" }, { "hid": "i18n-og-alt-fr-FR", "property": "og:locale:alternate", "content": "fr_FR" }, { "hid": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "hid": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "hid": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this changed, I think the i18n-alt-fr-FR
tag was added, shouldn't this have been there originally? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#locale-head
value is injected by useHead
. useHead
parameters is specified by resolved with useLocaleHead
i18n/specs/fixtures/basic_usage/pages/index.vue
Lines 65 to 76 in 08638d7
const i18nHead = useLocaleHead({ | |
addDirAttribute: true, | |
identifierAttribute: 'id', | |
addSeoAttributes: { canonicalQueries: ['page'] } | |
}) | |
useHead({ | |
htmlAttrs: { | |
lang: i18nHead.value.htmlAttrs!.lang | |
}, | |
link: [...(i18nHead.value.link || [])], | |
meta: [...(i18nHead.value.meta || [])] | |
}) |
This chaning is affected by this PR, or maybe useLocaleHead
has the issue. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out why this happened and fixed it by moving the check/rename of the iso
property (https://github.com/nuxt-modules/i18n/pull/3055/files#diff-39b2554fd18da165b59a6351b1aafff3714e2a80c1435f2de9706355b4d32351R518-R524) earlier in the code.
This is related to the way locales are normalized and merged if both string and object locales are configured in multiple layers. So the project layer had fr
configured which was normalized to { code: 'fr', language: 'fr' }
while a layer had configured { code: 'fr', iso: 'fr-FR' }
, which is why both language tags ended up in the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I've just reviewed your PR.
Please check it! 🙏
## Locale `iso` renamed to `language` | ||
|
||
The `iso` property on a locale object has been renamed to `language` as the original name refers to ISO standards which describe valid language tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add more explanation why we made this change, include PR link.
This would make it easier for users to understand.
#2449
specs/basic_usage.spec.ts
Outdated
@@ -141,7 +141,7 @@ describe('basic usage', async () => { | |||
) | |||
|
|||
expect(await getText(page, '#locale-head')).toMatchInlineSnapshot( | |||
`"{ "htmlAttrs": { "lang": "en" }, "link": [ { "hid": "i18n-alt-en", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "en" }, { "hid": "i18n-alt-fr", "rel": "alternate", "href": "/fr/nuxt-context-extension", "hreflang": "fr" }, { "hid": "i18n-alt-ja", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja" }, { "hid": "i18n-alt-ja-JP", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "hid": "i18n-alt-nl", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl" }, { "hid": "i18n-alt-nl-NL", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "hid": "i18n-alt-kr", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr" }, { "hid": "i18n-alt-kr-KO", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "hid": "i18n-xd", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "x-default" }, { "hid": "i18n-can", "rel": "canonical", "href": "/nuxt-context-extension" } ], "meta": [ { "hid": "i18n-og-url", "property": "og:url", "content": "/nuxt-context-extension" }, { "hid": "i18n-og", "property": "og:locale", "content": "en" }, { "hid": "i18n-og-alt-fr", "property": "og:locale:alternate", "content": "fr" }, { "hid": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "hid": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "hid": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"` | |||
`"{ "htmlAttrs": { "lang": "en" }, "link": [ { "hid": "i18n-alt-en", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "en" }, { "hid": "i18n-alt-fr", "rel": "alternate", "href": "/fr/nuxt-context-extension", "hreflang": "fr" }, { "hid": "i18n-alt-fr-FR", "rel": "alternate", "href": "/fr/nuxt-context-extension", "hreflang": "fr-FR" }, { "hid": "i18n-alt-ja", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja" }, { "hid": "i18n-alt-ja-JP", "rel": "alternate", "href": "/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "hid": "i18n-alt-nl", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl" }, { "hid": "i18n-alt-nl-NL", "rel": "alternate", "href": "/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "hid": "i18n-alt-kr", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr" }, { "hid": "i18n-alt-kr-KO", "rel": "alternate", "href": "/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "hid": "i18n-xd", "rel": "alternate", "href": "/nuxt-context-extension", "hreflang": "x-default" }, { "hid": "i18n-can", "rel": "canonical", "href": "/nuxt-context-extension" } ], "meta": [ { "hid": "i18n-og-url", "property": "og:url", "content": "/nuxt-context-extension" }, { "hid": "i18n-og", "property": "og:locale", "content": "en" }, { "hid": "i18n-og-alt-fr-FR", "property": "og:locale:alternate", "content": "fr_FR" }, { "hid": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "hid": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "hid": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#locale-head
value is injected by useHead
. useHead
parameters is specified by resolved with useLocaleHead
i18n/specs/fixtures/basic_usage/pages/index.vue
Lines 65 to 76 in 08638d7
const i18nHead = useLocaleHead({ | |
addDirAttribute: true, | |
identifierAttribute: 'id', | |
addSeoAttributes: { canonicalQueries: ['page'] } | |
}) | |
useHead({ | |
htmlAttrs: { | |
lang: i18nHead.value.htmlAttrs!.lang | |
}, | |
link: [...(i18nHead.value.link || [])], | |
meta: [...(i18nHead.value.meta || [])] | |
}) |
This chaning is affected by this PR, or maybe useLocaleHead
has the issue. 🤔
@kazupon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
Thank you! 💚
* fix: rename locale property `iso` to `language` * refactor: rename parameters * fix: locale `language` merging * docs: expand `iso` rename explanation
Adresses the change in nuxt-modules/i18n#3055
* chore(deps): update dependency @nuxtjs/i18n to v8.4.0 * Fixed renamed `iso`->`language` Adresses the change in nuxt-modules/i18n#3055 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
🔗 Linked issue
locales
#2449❓ Type of change
📚 Description
As discussed in #2449, this renames the
iso
key tolanguage
to better fit the usage of the property.This PR should be backwards compatible but will log a warning when
iso
is being used instead oflanguage
. We should again remember to remove the backwards compatibility before releasing v9.📝 Checklist