i18n infopages

This commit is contained in:
lovebird 2025-03-10 13:13:59 +01:00
parent df27705b43
commit ae11c80051
10 changed files with 134 additions and 82 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
export default {
"environment": "build",
"environment": "dev",
"isSsrBuild": false,
"projectBase": "",
"publicDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\public\\",
"rootDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\",
"mode": "production",
"outDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\dist\\",
"assetsDir": "_astro",
"mode": "dev",
"outDir": "dist",
"assetsDir": "/_astro",
"sourcemap": false,
"assetFileNames": "/_astro/[name]@[width].[hash][extname]"
}

View File

@ -26,16 +26,12 @@
"href": "/helpcenter/home",
"text": "Help"
},
{
"href": "/infopages/terms",
"text": "Terms"
},
{
"href": "/infopages/privacy",
"text": "Privacy"
},
{
"href": "/forms/contact",
"href": "/infopages/contact",
"text": "Contact"
},
{

View File

@ -1,44 +1,44 @@
import { translate } from '../base/i18n.js'
import { I18N_SOURCE_LANGUAGE } from 'config/config.js'
import config from "./config.json"
import pMap from 'p-map'
export const items = async (opts: { locale: string }) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, opts.locale)
return [
{
"href": `/${opts.locale}`,
"title": _T("Home"),
"ariaLabel": "Home",
"class": "hover:text-orange-600"
},
{
"href": `/resources/home`,
"title": _T("Resources"),
"ariaLabel": "Resources",
"class": "hover:text-orange-600"
}
]
}
export const footer_left = async ( locale: string ) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale)
return await pMap(config.footer_left, async (item) => {
return {
"href": `${item.href}`,
"title": await _T(item.text),
"ariaLabel": item.text,
"class": "hover:text-orange-600"
}
});
}
export const footer_right = async ( locale: string ) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale)
return await pMap(config.footer_right, async (item) => {
return {
"href": `/${item.href}`,
"title": await _T(item.text),
"ariaLabel": item.text,
"class": "hover:text-orange-600"
}
});
import { translate } from '../base/i18n.js'
import { I18N_SOURCE_LANGUAGE } from 'config/config.js'
import config from "./config.json"
import pMap from 'p-map'
export const items = async (opts: { locale: string }) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, opts.locale)
return [
{
"href": `/${opts.locale}`,
"title": _T("Home"),
"ariaLabel": "Home",
"class": "hover:text-orange-600"
},
{
"href": `/resources/home`,
"title": _T("Resources"),
"ariaLabel": "Resources",
"class": "hover:text-orange-600"
}
]
}
export const footer_left = async ( locale: string ) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale)
return await pMap(config.footer_left, async (item) => {
return {
"href": `/${locale}${item.href}`,
"title": await _T(item.text),
"ariaLabel": item.text,
"class": "hover:text-orange-600"
}
});
}
export const footer_right = async ( locale: string ) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale)
return await pMap(config.footer_right, async (item) => {
return {
"href": `/${item.href}`,
"title": await _T(item.text),
"ariaLabel": item.text,
"class": "hover:text-orange-600"
}
});
}

View File

@ -1,21 +1,22 @@
---
import { I18N_SOURCE_LANGUAGE } from "config/config.js"
import { translate, IOptions } from '@/base/i18n.js'
export interface Props extends IOptions {
language?: string,
clazz?:string
}
const {
language = Astro.currentLocale,
clazz = '',
...rest
} = Astro.props
const content = await Astro.slots.render('default')
const translatedText = await translate(content, I18N_SOURCE_LANGUAGE, language, rest)
---
<div data-widget="polymech.i18n" class={clazz}>
{translatedText}
</div>
---
import { I18N_SOURCE_LANGUAGE } from "config/config.js"
import { translate, IOptions } from '@/base/i18n.js'
export interface Props extends IOptions {
language?: string,
clazz?:string
}
const {
language = Astro.currentLocale,
clazz = '',
...rest
} = Astro.props
const content = await Astro.slots.render('default')
const translatedText = await translate(content, I18N_SOURCE_LANGUAGE, language, rest)
console.log('translatedText', translatedText)
---
<div data-widget="polymech.i18n" class={clazz}>
{translatedText}
</div>

View File

@ -19,7 +19,7 @@ const pages = [
},
{
name: "Forms",
links: [{ href: "/forms/contact", text: "Contact" }],
links: [{ href: "/forms/contact2", text: "Contact" }],
},
{
name: "System",

View File

@ -0,0 +1,17 @@
## Contact
## Administration & Sales
[sales@plastic-hub.com](mailto:/sales@plastic-hub.com)
Anne Barbier - +34 691 952 287
Address - Factory
Polígono Can Clapers
Carrer Can peric 11, 1B
08181 Sentmenat ~ Spain
VAT - ID : ESY0100830N
[Get Directions](https://www.google.com/maps/place/Plastic+Hub/@41.6093789,2.1399009,17z/data=!3m1!4b1!4m5!3m4!1s0x12a4eb80cfabbbfd:0x2cd16f2aff436ed!8m2!3d41.6094019!4d2.1421267)

View File

@ -1,14 +1,20 @@
---
import BaseLayout from "./BaseLayout.astro";
const { frontmatter } = Astro.props;
import Wrapper from "@/components/containers/Wrapper.astro";
import { I18N_SOURCE_LANGUAGE } from "config/config.js"
import { translate } from '@/base/i18n.js'
import { component } from '@/base/index.js'
const { frontmatter } = Astro.props;
const content = await Astro.slots.render('default')
const translatedText = await translate(content, I18N_SOURCE_LANGUAGE, Astro.currentLocale)
const Markup = await component(translatedText, Astro.currentLocale, frontmatter)
---
<BaseLayout>
<Wrapper>
<section>
<div class="grid sm:grid-cols-1 lg:grid-cols-1 xl:grid-cols-1 gap-2">
<div class="simple-prose-styles py-2 lg:col-start-3 justify-end p-4">
<slot />
<div class="grid sm:grid-cols-1 lg:grid-cols-1 xl:grid-cols-1 gap-2 text-neutral-500 markdown-content">
<div class="py-2 p-4 bg-white rounded-xl">
<Markup/>
</div>
</div>
</section>

View File

@ -0,0 +1,35 @@
---
import StoreLayout from '@/layouts/StoreLayout.astro'
import { getCollection } from 'astro:content'
import { LANGUAGES_PROD as LANGUAGES } from "config/config.js"
import InfoPagesLayout from '@/layouts/InfoPagesLayout.astro';
export async function getStaticPaths()
{
const view = 'infopages'
const items = await getCollection(view)
const all: unknown[] = []
LANGUAGES.forEach((lang) => {
items.forEach((item) => {
all.push({
params: {
locale: lang,
path: item.slug,
},
props: {
page: item,
locale: lang,
path: item.id,
view
},
trailingSlash: false
})
})
})
return all
}
const { page } = Astro.props;
const { Content } = await page.render();
---
<InfoPagesLayout frontmatter={page.data}>
<Content />
</InfoPagesLayout>

View File

@ -173,9 +173,6 @@
.markdown-content {
@apply prose dark:prose-invert max-w-none font-mono;
}