Skip to content
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

adds i18n docs #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions docs/nuxt-client/Internationalisation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
sidebar_position: 12
---
# Internationalisation (I18n)

[Relevant Docs of VueI18n](https://vue-i18n.intlify.dev/guide/advanced/typescript.html#typescript-support)

## How to Use in a component

1. Script Setup

```ts
<script lang="ts" setup>
// import original i18n composable
import { useI18n } from "vue-i18n";
// import our I18n config for typehinting
import { I18nConfig } from "@/plugins/i18n";

const { t } = useI18n<I18nConfig>();

const translated = t('key.with.typehinting!');

</script>

```

```html
<template>
{{ t('works.in.template.too!') }}
</template>

```


2. DefineComponent Setup

```ts
<script lang="ts" setup>
// import original i18n composable
import { useI18n } from "vue-i18n";
// import our I18n config for typehinting
import { I18nConfig } from "@/plugins/i18n";

export default defineComponent({
setup() {
const { t } = useI18n<I18nConfig>();

const translated = t('key.with.typehinting!');

return {
t // return t-Function to use it in the template!
}
}
})


</script>
```

```html
<template>
{{ t('works.in.template.too!') }}
</template>

```

3. Global Setup (no typehinting)

```ts
<script lang="ts" setup>
// Component Code
</script>
```

```html
<template>
{{ $t('$t.does.not.have.typehinting') }}
</template>

```

Loading