astro native i18n + i18n utils
This commit is contained in:
parent
99ef7634e3
commit
b7ce5b7f20
16 changed files with 266 additions and 163 deletions
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
import { astroI18n } from "astro-i18n";
|
||||
astroI18n.init(Astro);
|
||||
const locale = Astro.currentLocale;
|
||||
|
||||
import "../styles/style.css";
|
||||
|
||||
|
@ -11,7 +10,7 @@ import Footer from "../components/Footer.astro";
|
|||
const { pageTitle } = Astro.props;
|
||||
---
|
||||
|
||||
<html lang={astroI18n.langCode} dir="ltr">
|
||||
<html lang={locale} dir="ltr">
|
||||
<Head pageTitle={pageTitle} />
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
|
|
|
@ -1,33 +1,27 @@
|
|||
---
|
||||
import { l, t, astroI18n } from "astro-i18n";
|
||||
// import AstroImage from "../components/AstroImage.astro";
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
import BaseLayout from '../layouts/BaseLayout.astro'
|
||||
import { getLangFromUrl, useTranslations } from '../utils/i18n'
|
||||
|
||||
const { frontmatter, image, title } = Astro.props;
|
||||
const publishedDate = new Date(frontmatter.pubDate);
|
||||
const localizedDate = new Intl.DateTimeFormat(astroI18n.langCode, {
|
||||
dateStyle: "long",
|
||||
}).format(publishedDate);
|
||||
const locale = getLangFromUrl(Astro.url)
|
||||
const t = useTranslations(locale)
|
||||
|
||||
const { frontmatter, image, title } = Astro.props
|
||||
const publishedDate = new Date(frontmatter.pubDate)
|
||||
const localizedDate = new Intl.DateTimeFormat(locale, {
|
||||
dateStyle: 'long'
|
||||
}).format(publishedDate)
|
||||
---
|
||||
|
||||
<BaseLayout pageTitle={title}>
|
||||
<p>
|
||||
Publié le : <time datetime={frontmatter.pubDate}>
|
||||
{t('article.published')} : <time datetime={frontmatter.pubDate}>
|
||||
{localizedDate}.
|
||||
</time>
|
||||
</p>
|
||||
<p>
|
||||
{
|
||||
t("article.published", {
|
||||
datetime: frontmatter.pubDate,
|
||||
options: { dateStyle: "long" },
|
||||
})
|
||||
}
|
||||
</p>
|
||||
<div class="tags">
|
||||
<div class='tags'>
|
||||
{
|
||||
frontmatter.tags.map((tag) => (
|
||||
<p class="tag">
|
||||
<p class='tag'>
|
||||
<a href={l(`/tags/${[tag]}`)}>{tag}</a>
|
||||
</p>
|
||||
))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue