Skip to content

Hyphens in placeholders causing error Unterminated closing brace in vue-i18n@9 #1796

@rs3d

Description

@rs3d

Reporting a bug?

Using a placeholder with hyphens in [email protected] is causing errors

const messages = {
  en: {
    message: {
      "message-with-placeholder-using-hyphens":
        "My message with {placeholder-hyphens}.", 
    },
  },
};
// usage:
 $t("message.message-with-placeholder-using-hyphens", {
   "placeholder-hyphens": 'XXXX'
});

Error message

1  |  My message with {placeholder-hyphens}.

Using <i18n-t> is breaking component rendering

<i18n-t
      keypath="message.message-with-placeholder-using-hyphens"
      v-if="false"
    >
      <template #placeholder-hyphens>
        {{ $t("message.hello") }}
      </template>
    </i18n-t>

Demo: https://codesandbox.io/p/devbox/vuei18n-hyphen-vxst9x?file=%2Fsrc%2FApp.vue
(<i18n> can be enabled via v-if="true")

Expected behavior

Above message-syntax works in vue-i18n@8

Reproduction

https://codesandbox.io/p/devbox/vuei18n-hyphen-vxst9x?file=%2Fsrc%2FApp.vue

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13700H
    Memory: 20.88 GB / 63.68 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.14.18 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.81)
    Internet Explorer: 11.0.22621.1

Screenshot

$t error and output
image
image

<i18n-t> error
image

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugBug or Bug fixes🔨 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