2021-12-23 19:27:08 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
// see ../compoables/locale.ts for the implementation
|
2021-11-16 15:37:36 +00:00
|
|
|
const locales = useLocales()
|
|
|
|
const locale = useLocale()
|
|
|
|
const date = useLocaleDate(new Date('2016-10-26') /* NUXT_BIRTHDAY */)
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-12-23 19:27:08 +00:00
|
|
|
<NuxtExampleLayout :show-tips="true" example="locale">
|
|
|
|
<h1 class="text-xl opacity-50">
|
|
|
|
Nuxt birthday
|
|
|
|
</h1>
|
|
|
|
<p class="text-4xl">
|
|
|
|
{{ date }}
|
|
|
|
</p>
|
|
|
|
<div class="mt-4" />
|
|
|
|
<label for="locale-chooser">Preview a different locale</label>
|
|
|
|
<select id="locale-chooser" v-model="locale" class="m-auto w-50 border n-border-base rounded p-1">
|
2021-11-16 15:37:36 +00:00
|
|
|
<option v-for="l of locales" :key="l" :value="l">
|
|
|
|
{{ l }}
|
|
|
|
</option>
|
|
|
|
</select>
|
2021-12-23 19:27:08 +00:00
|
|
|
|
|
|
|
<template #tips>
|
|
|
|
<div>
|
|
|
|
You can right click to "View Page Source" and see that Nuxt renders the correct date in SSR based on visitor's locale.
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</NuxtExampleLayout>
|
2021-11-16 15:37:36 +00:00
|
|
|
</template>
|