-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: playground restructure (#3173)
- Loading branch information
1 parent
433492f
commit beb8e58
Showing
40 changed files
with
175 additions
and
297 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,125 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
const { t, rt, tm, strategy, locale, locales, setLocale } = useI18n() | ||
const localePath = useLocalePath() | ||
const switchLocalePath = useSwitchLocalePath() | ||
function getLocaleName(code: string) { | ||
const locale = locales.value.find(i => i.code === code) | ||
return locale ? locale.name : code | ||
} | ||
const availableLocales = computed(() => { | ||
return locales.value.filter(i => i.code !== locale.value) | ||
}) | ||
const i = tm('items') || [] | ||
const items = i.map(item => rt(item?.name ?? '')) | ||
definePageMeta({ | ||
title: 'pages.title.top', | ||
pageTransition: { | ||
name: 'page', | ||
mode: 'out-in', | ||
onBeforeEnter: async () => { | ||
const { finalizePendingLocaleChange } = useNuxtApp().$i18n | ||
await finalizePendingLocaleChange() | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h1>Demo: Nuxt 3</h1> | ||
<section> | ||
<p>Current Language: {{ getLocaleName(locale) }}</p> | ||
<p>Current Strategy: {{ strategy }}</p> | ||
</section> | ||
<section> | ||
<h3 class="margin-bottom: 0;">Language switchers</h3> | ||
<div style="display: flex; column-gap: 1em"> | ||
<div> | ||
<span>`switchLocalePath` switcher</span> | ||
<ul> | ||
<li v-for="locale in availableLocales" :key="locale.code"> | ||
<NuxtLink :to="switchLocalePath(locale.code) || ''">{{ locale.name }}</NuxtLink> | ||
</li> | ||
</ul> | ||
</div> | ||
<div> | ||
<span>`setLocale` switcher</span> | ||
<ul> | ||
<li v-for="locale in availableLocales" :key="locale.code"> | ||
<a href="javascript:void(0)" @click="setLocale(locale.code)">{{ locale.name }}</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</section> | ||
<section> | ||
<h3>Pages</h3> | ||
<ul> | ||
<li> | ||
<NuxtLink :to="localePath('index')">Home</NuxtLink> | ||
</li> | ||
<li> | ||
<NuxtLink :to="localePath({ name: 'about' })">About</NuxtLink> | ||
</li> | ||
<li> | ||
<NuxtLink :to="localePath({ name: 'blog' })">Blog</NuxtLink> | ||
</li> | ||
<li> | ||
<NuxtLink :to="localePath({ name: 'server' })">Server</NuxtLink> | ||
</li> | ||
<li> | ||
<NuxtLink :to="localePath({ name: 'category-id', params: { id: 'foo' } })">Category</NuxtLink> | ||
</li> | ||
<li> | ||
<NuxtLinkLocale :to="{ name: 'history' }" class="history-link">History</NuxtLinkLocale> | ||
</li> | ||
<li> | ||
<NuxtLinkLocale to="index" locale="ja" activeClass="link-active">Home (Japanese)</NuxtLinkLocale> | ||
</li> | ||
<li> | ||
<NuxtLinkLocale :to="{ name: 'products' }" class="products-link">Products</NuxtLinkLocale> | ||
</li> | ||
</ul> | ||
</section> | ||
<section> | ||
<h3>Translations</h3> | ||
<p>{{ $t('hello', { name: 'nuxt3' }) }}</p> | ||
<p>{{ $t('snakeCaseText') }}</p> | ||
<p>{{ $t('pascalCaseText') }}</p> | ||
<p>{{ $t('bar.buz', { name: 'buz' }) }}</p> | ||
<p>{{ $t('settings.profile', {}, { locale: 'en' }) }}</p> | ||
<p>{{ $t('tag') }}</p> | ||
<div>v-t directive: <code v-t="{ path: 'hello', args: { name: 'v-t' } }"></code></div> | ||
<p>Items</p> | ||
<ul> | ||
<li v-for="item in items">{{ item }}</li> | ||
</ul> | ||
</section> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
section { | ||
margin: 2em 0em; | ||
} | ||
.page-enter-active, | ||
.page-leave-active { | ||
transition: opacity 0.5s ease; | ||
} | ||
.page-enter-from, | ||
.page-leave-to { | ||
opacity: 0; | ||
} | ||
.link-active { | ||
color: rgb(51, 175, 51); | ||
} | ||
</style> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.