Skip to content

How to use β€” i18n ​

Register translations on defineRaclettePluginFrontend in frontend/index.ts, then read them with usePluginApi().$i18n in widgets.

Register locales ​

typescript
export default defineRaclettePluginFrontend({
  i18n: {
    "en-EU": {
      myFeature: { title: "Hello" },
    },
    "de-EU": {
      myFeature: { title: "Hallo" },
    },
  },
})

Use the same locale ids as your app (raclette.config β€” Getting started).

Use in a widget ​

typescript
const { $i18n } = usePluginApi()
const title = computed(() => $i18n.t("myFeature.title"))

Another plugin’s strings: usePluginApi("author__other").$i18n.

Tips ​

  • Nested keys (feature.action) stay easier to maintain than long flat names.
  • Provide at least en-EU; do not assume every locale exists at runtime.

See also ​