feat: rebrand to ConvertX-CN, fix TypeScript error, add docs

- Fix TypeScript TS2345 error in i18n/service.ts by parsing cookie from header
- Rebrand all ConvertX references to ConvertX-CN
- Change default language from en to zh-TW
- Fix footer to always display English 'Powered by ConvertX-CN'
- Update GitHub links to pi-docket/ConvertX-CN
- Add /docs folder with documentation:
  - getting-started.md
  - configuration.md
  - converters.md
  - i18n.md
- Update all locale files with new branding
This commit is contained in:
Your Name 2026-01-20 10:29:17 +08:00
parent a6770c0d51
commit 53b83b425f
18 changed files with 315 additions and 41 deletions

View file

@ -13,14 +13,16 @@ export interface LocaleConfig {
}
export const supportedLocales: LocaleConfig[] = [
{ code: "en", name: "English", nativeName: "English" },
{ code: "zh-TW", name: "Chinese (Traditional)", nativeName: "繁體中文" },
{ code: "zh-CN", name: "Chinese (Simplified)", nativeName: "简体中文" },
{ code: "en", name: "English", nativeName: "English" },
{ code: "ja", name: "Japanese", nativeName: "日本語" },
{ code: "ko", name: "Korean", nativeName: "한국어" },
];
export const defaultLocale: SupportedLocale = "en";
// Default to zh-TW, fallback to en
export const defaultLocale: SupportedLocale = "zh-TW";
export const fallbackLocale: SupportedLocale = "en";
// Type definitions for translation keys
export type TranslationData = typeof en;

View file

@ -1,8 +1,7 @@
import { Elysia, t } from "elysia";
import { Elysia } from "elysia";
import {
type SupportedLocale,
createTranslator,
defaultLocale,
detectLocale,
getLocale,
} from "../i18n";
@ -12,29 +11,31 @@ import {
* Adds locale detection and translator to the context
*/
export const localeService = new Elysia({ name: "locale/service" })
.model({
localeSession: t.Cookie({
locale: t.Optional(t.String()),
}),
})
.derive({ as: "global" }, ({ cookie, request }) => {
// Get locale from cookie or detect from Accept-Language header
const cookieLocale = cookie.locale?.value;
.derive({ as: "global" }, ({ request }) => {
// Get locale from cookie (parsed from headers) or detect from Accept-Language header
const cookieHeader = request.headers.get("cookie") ?? "";
const acceptLanguage = request.headers.get("accept-language") ?? undefined;
// Parse locale from cookie string
let cookieLocale: string | undefined;
const localeMatch = cookieHeader.match(/locale=([^;]+)/);
if (localeMatch) {
cookieLocale = localeMatch[1];
}
let locale: SupportedLocale;
if (cookieLocale) {
if (cookieLocale && typeof cookieLocale === "string") {
locale = getLocale(cookieLocale);
} else {
locale = detectLocale(acceptLanguage);
}
const t = createTranslator(locale);
const translator = createTranslator(locale);
return {
locale,
t,
t: translator,
};
});