Skip to content

te returns false if the key contains a dot #2375

@Me-Phew

Description

@Me-Phew

Reporting a bug?

If the key has a dot (eg. a.b.c) t('a.b.c') returns a correct translation, but te always returns false

This is problematic in projects that use a flat locale files structure like:

{
  "key.exampleNestedKey": "Translation",
  "key2.exampleNestedKey.evenMoreNesting": "Translation"
}

Expected behavior

te returns true for dotted keys if they exist in the current locale

Reproduction

Stackblitz

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^4.2.3 => 4.3.4 
    vite: ^4.4.9 => 4.4.9 
    vue: ^3.3.4 => 3.3.4 
    vue-i18n: ^9.3.0 => 9.3.0 
    vue-tsc: ^1.8.8 => 1.8.10

Screenshot

No response

Additional context

This is actually a duplicate of an old issue from the v8 version of Vue I18n

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Review NeededRequest for review comments🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions