-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
408 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<div> | ||
<div class="article-id"> | ||
id: {{ params.id }} | ||
</div> | ||
<div class="article-data"> | ||
articles: {{ articles }} | ||
</div> | ||
|
||
<NuxtLink | ||
class="link-news-1" | ||
:to="$localeRoute({ name: 'news-id', params: { id: '1' } })" | ||
> | ||
news-1 | ||
</NuxtLink> | ||
|
||
<div class="locale-switcher"> | ||
<NuxtLink | ||
class="locale-en" | ||
:to="$switchLocaleRoute('en')" | ||
> | ||
en | ||
</NuxtLink> | ||
<NuxtLink | ||
class="locale-ru" | ||
:to="$switchLocaleRoute('ru')" | ||
> | ||
ru | ||
</NuxtLink> | ||
<NuxtLink | ||
class="locale-de" | ||
:to="$switchLocaleRoute('de')" | ||
> | ||
de | ||
</NuxtLink> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const { params } = useRoute() | ||
const { $switchLocaleRoute } = useI18n() | ||
const { data: articles } = await useAsyncData( | ||
`articles-${params.id}`, | ||
async () => { | ||
return await $fetch('/api/getArticles', { | ||
query: { | ||
id: params.id, | ||
}, | ||
}) | ||
}, | ||
) | ||
</script> | ||
|
||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<template> | ||
<div> | ||
<h1>{{ $t('page.title') }}</h1> | ||
<p id="content"> | ||
<i18n-t keypath="page.content" /> | ||
</p> | ||
<p id="username"> | ||
<i18n-t | ||
keypath="page.greeting" | ||
:params="{ name: 'John' }" | ||
/> | ||
</p> | ||
<p id="plural"> | ||
<i18n-t | ||
keypath="page.items" | ||
:plural="itemCount" | ||
/> | ||
</p> | ||
<p id="html-content"> | ||
<i18n-t | ||
keypath="page.htmlContent" | ||
:html="true" | ||
/> | ||
</p> | ||
|
||
<NuxtLink | ||
id="locale-en" | ||
:to="$switchLocaleRoute('en')" | ||
> | ||
Switch to en | ||
</NuxtLink> | ||
<NuxtLink | ||
id="locale-de" | ||
:to="$switchLocaleRoute('de')" | ||
> | ||
Switch to de | ||
</NuxtLink> | ||
|
||
<client-only> | ||
<div class="locale-route-data"> | ||
{{ $localeRoute({ name: 'locale-conf' }, 'en') }} | ||
</div> | ||
<div class="locale-route-data"> | ||
{{ $localeRoute({ name: 'locale-conf' }, 'de') }} | ||
</div> | ||
</client-only> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { useNuxtApp } from '#imports' | ||
const { $defineI18nRoute } = useNuxtApp() | ||
// Define translations directly on the page | ||
$defineI18nRoute({ | ||
locales: { | ||
en: { | ||
page: { | ||
title: 'Locale Test Page', | ||
content: 'This is a content area.', | ||
greeting: 'Hello, {name}!', | ||
items: 'You have {count} items.', | ||
htmlContent: '<strong>Bold Text</strong> with HTML content.', | ||
}, | ||
}, | ||
de: { | ||
page: { | ||
title: 'Sprachtestseite', | ||
content: 'Dies ist ein Inhaltsbereich.', | ||
greeting: 'Hallo, {name}!', | ||
items: 'Sie haben {count} Artikel.', | ||
htmlContent: '<strong>Fetter Text</strong> mit HTML-Inhalt.', | ||
}, | ||
}, | ||
}, | ||
localeRoutes: { | ||
de: '/locale-conf-modify', | ||
}, | ||
}) | ||
const itemCount = 2 | ||
</script> |
Oops, something went wrong.