From 588a536e873f515bd97a8c3ba20b065c4c27daf2 Mon Sep 17 00:00:00 2001 From: twystpaki <50775957+twystpaki@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:02:23 +0700 Subject: [PATCH] feat: add Thai translation (#264) * Create th.ts Created i18n Thai translation file. * Update translation.ts Added Thai language support. * Update config.ts Added Spanish (es) and Thai (th) to commented possible values for `lang` key. * Create README.th.md Created Thai version of README. * Update README.md Added navigation/link to Thai version of README. --- README.md | 3 +- README.th.md | 59 ++++++++++++++++++++++++++++++++++++++++ src/config.ts | 2 +- src/i18n/languages/th.ts | 38 ++++++++++++++++++++++++++ src/i18n/translation.ts | 5 +++- 5 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 README.th.md create mode 100644 src/i18n/languages/th.ts diff --git a/README.md b/README.md index 425e58e6..bd5bc73e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ A static blog template built with [Astro](https://astro.build). [**🌏 中文**](https://github.com/saicaca/fuwari/blob/main/README.zh-CN.md)   /    [**🌏 日本語**](https://github.com/saicaca/fuwari/blob/main/README.ja-JP.md)   /    [**🌏 한국어**](https://github.com/saicaca/fuwari/blob/main/README.ko.md)   /    -[**🌏 Español**](https://github.com/saicaca/fuwari/blob/main/README.es.md) +[**🌏 Español**](https://github.com/saicaca/fuwari/blob/main/README.es.md)   /    +[**🌏 ไทย**](https://github.com/saicaca/fuwari/blob/main/README.th.md) > README version: `2024-09-10` diff --git a/README.th.md b/README.th.md new file mode 100644 index 00000000..6767f3d0 --- /dev/null +++ b/README.th.md @@ -0,0 +1,59 @@ +# 🍥Fuwari + +แม่แบบสำหรับเว็บบล็อกแบบ static สร้างด้วย [Astro](https://astro.build) + +[**🖥️ ตัวอย่างการใช้งานจริง (Vercel)**](https://fuwari.vercel.app)   /    +[**📦 เวอร์ชั่นเก่าสำหรับ Hexo**](https://github.com/saicaca/hexo-theme-vivia) + +> เวอร์ชั่นของ README: `2024-09-10` + +![ภาพตัวอย่าง](https://raw.githubusercontent.com/saicaca/resource/main/fuwari/home.png) + +## ✨ คุณสมบัติ + +- [x] สร้างด้วย [Astro](https://astro.build) และ [Tailwind CSS](https://tailwindcss.com) +- [x] มีอนิเมชั่นและการเปลี่ยนหน้าอย่างลื่นไหล +- [x] รองรับโหมดสว่าง / โหมดมืด +- [x] ปรับแต่งสีธีมและแบนเนอร์ได้ +- [x] Responsive design (หน้าตาเว็บปรับเปลี่ยนตามขนาดจอ) +- [ ] การแสดงความคิดเห็น +- [x] การค้นหา +- [ ] TOC (สารบัญ) + +## 🚀 วิธีใช้งาน + +1. [Generate repository ใหม่](https://github.com/saicaca/fuwari/generate)ขึ้นมาจากแม่แบบนี้ หรือจะ fork repository นี้ก็ได้ +2. เริ่มแก้ไขบล็อกของคุณแบบ local โดยการ clone repository ของคุณ (จากข้อ 1) ไว้ในเครื่องของคุณ แล้วรันคำสั่ง `pnpm install` และ `pnpm add sharp` เพื่อติดตั้ง dependencies ที่จำเป็น + - ติดตั้ง [pnpm](https://pnpm.io) ด้วยคำสั่ง `npm install -g pnpm` ถ้ายังไม่เคยติดตั้ง +3. แก้ไขไฟล์การตั้งค่า `src/config.ts` เพื่อปรับแต่งบล็อกของคุณ +4. รันคำสั่ง `pnpm new-post ` เพื่อสร้างโพสต์ใหม่ใน `src/content/posts/` และแก้ไขไฟล์โพสต์นั้นๆ ให้สมบูรณ์ +5. Deploy เว็บบล็อกของคุณไปยัง Vercel, Netlify, GitHub Pages หรือบริการอื่นๆ โดยอ้างอิงวิธีการจาก[คู่มือนี้](https://docs.astro.build/en/guides/deploy/) อย่าลืมแก้ไขการตั้งค่าเว็บไซต์ในไฟล์ `astro.config.mjs` ก่อนที่คุณจะ deploy เว็บ + +## ⚙️ Frontmatter ของโพสต์ + +```yaml +--- +title: โพสต์แรกของฉัน +published: 2023-09-09 +description: นี่คือโพสต์แรกของเว็บบล็อก Astro อันใหม่ของฉัน +image: ./cover.jpg +tags: [Foo, Bar] +category: Front-end +draft: false +lang: jp # เขียนค่านี้เมื่อภาษาของโพสต์นั้นๆ แตกต่างจากภาษาของเว็บไซต์ที่ตั้งค่าไว้ใน `config.ts` เท่านั้น +--- +``` + +## 🧞 คำสั่ง + +คำสั่งที่รันได้ใน terminal จาก root ของโปรเจค: + +| คำสั่ง | ผลที่เกิด | +|:------------------------------------|:--------------------------------------------------| +| `pnpm install` และ `pnpm add sharp` | ติดตั้ง dependencies | +| `pnpm dev` | เปิดเซิร์ฟเวอร์เพื่อพัฒนาเว็บแบบ local ที่ `localhost:4321` | +| `pnpm build` | Build เว็บไซต์แบบพร้อมใช้งานจริงไปยังโฟลเดอร์ `./dist/` | +| `pnpm preview` | ดูตัวอย่าง build ของคุณแบบ local ก่อนที่จะ deploy จริง | +| `pnpm new-post ` | สร้างโพสต์ใหม่ | +| `pnpm astro ...` | รันคำสั่ง CLI เช่น `astro add`, `astro check` | +| `pnpm astro --help` | ดูข้อมูลเพิ่มเติมเกี่ยวกับ Astro CLI | diff --git a/src/config.ts b/src/config.ts index d2c38b58..e33372db 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,7 +9,7 @@ import { LinkPreset } from './types/config' export const siteConfig: SiteConfig = { title: 'Fuwari', subtitle: 'Demo Site', - lang: 'en', // 'en', 'zh_CN', 'zh_TW', 'ja', 'ko' + lang: 'en', // 'en', 'zh_CN', 'zh_TW', 'ja', 'ko', 'es', 'th' themeColor: { hue: 250, // Default hue for the theme color, from 0 to 360. e.g. red: 0, teal: 200, cyan: 250, pink: 345 fixed: false, // Hide the theme color picker for visitors diff --git a/src/i18n/languages/th.ts b/src/i18n/languages/th.ts new file mode 100644 index 00000000..44787e7a --- /dev/null +++ b/src/i18n/languages/th.ts @@ -0,0 +1,38 @@ +import Key from '../i18nKey' +import type { Translation } from '../translation' + +export const th: Translation = { + [Key.home]: 'หน้าแรก', + [Key.about]: 'เกี่ยวกับ', + [Key.archive]: 'คลัง', + [Key.search]: 'ค้นหา', + + [Key.tags]: 'ป้ายกำกับ', + [Key.categories]: 'หมวดหมู่', + [Key.recentPosts]: 'โพสต์ล่าสุด', + + [Key.comments]: 'ความคิดเห็น', + + [Key.untitled]: 'ไม่ได้ตั้งชื่อ', + [Key.uncategorized]: 'ไม่ได้จัดหมวดหมู่', + [Key.noTags]: 'ไม่มีป้ายกำกับ', + + [Key.wordCount]: 'คำ', + [Key.wordsCount]: 'คำ', + [Key.minuteCount]: 'นาที', + [Key.minutesCount]: 'นาที', + [Key.postCount]: 'โพสต์', + [Key.postsCount]: 'โพสต์', + + [Key.themeColor]: 'สีของธีม', + + [Key.lightMode]: 'สว่าง', + [Key.darkMode]: 'มืด', + [Key.systemMode]: 'ตามระบบ', + + [Key.more]: 'ดูเพิ่ม', + + [Key.author]: 'ผู้เขียน', + [Key.publishedAt]: 'เผยแพร่เมื่อ', + [Key.license]: 'สัญญาอนุญาต', +} diff --git a/src/i18n/translation.ts b/src/i18n/translation.ts index 38934fb3..8ccf887a 100644 --- a/src/i18n/translation.ts +++ b/src/i18n/translation.ts @@ -4,6 +4,7 @@ import { en } from './languages/en' import { es } from './languages/es' import { ja } from './languages/ja' import { ko } from './languages/ko' +import { th } from './languages/th' import { zh_CN } from './languages/zh_CN' import { zh_TW } from './languages/zh_TW' @@ -25,6 +26,8 @@ const map: { [key: string]: Translation } = { ja_jp: ja, ko: ko, ko_kr: ko, + th: th, + th_th: th, } export function getTranslation(lang: string): Translation { @@ -34,4 +37,4 @@ export function getTranslation(lang: string): Translation { export function i18n(key: I18nKey): string { const lang = siteConfig.lang || 'en' return getTranslation(lang)[key] -} \ No newline at end of file +}