Skip to content

Automatic i18n locale matching misses zh-Hant-TW and zh-Hans-CN #7428

Open

Description

@fernandezbaptiste

Hullo folks,

I’m doing some research for Tessl Code Review and we ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:

We checked the finding against the current code.

Environment / version

Nuxt integration, @nuxt/ui 4.12.0 source at 48d76af5. This is a focused check of the build-time locale resolver, without launching a Nuxt application.

Description

Automatic locale matching resolves zh-TW and zh-CN, but adding their script subtags makes the same regional locales unresolved. The generated i18n plugin then omits those configured locale codes.

Reproduction

From a checkout, this minimal check exercises the exported resolver:

import { resolveLocaleKey } from './src/utils/locales'

const keys = ['en', 'zh_cn', 'zh_tw']
console.log(resolveLocaleKey('zh-TW', keys))      // zh_tw
console.log(resolveLocaleKey('zh-CN', keys))      // zh_cn
console.log(resolveLocaleKey('zh-Hant-TW', keys)) // undefined
console.log(resolveLocaleKey('zh-Hans-CN', keys)) // undefined

We executed the resolver’s current function unchanged in an isolated Bun check and got these results. This concerns Nuxt module configuration, rather than a component-only playground example.

Expected: the region-qualified tags should select zh_tw and zh_cn, respectively. Language-only zh can remain ambiguous.

Actual: the candidate list tries the complete tag and then only its language. It never tries zh_tw or zh_cn after removing a script subtag, and both regional matches make the language-only fallback ambiguous. Plugin generation skips unresolved entries.

Using zh-TW / zh-CN as the configured codes, or passing an explicit UI locale, provides a workaround.

Original Tessl finding. Does this look worth addressing, or have we missed some intended behaviour?

Tessl reviews code using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced. We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.

Baptiste

Activity

  1. coderabbitai commented on Nov 16, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7429 - fix(module): resolve @nuxtjs/i18n locales with a script subtag [open]
    #7152 - feat(App): follow the @nuxtjs/i18n locale [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageAwaiting initial review and prioritization

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions