Files
zhaoguiyang.site/src/i18n/ui.ts
joyzhao a446ce68bd feat(i18n): add slogans and update translations for multiple pages
Add new slogan translations for projects and blog pages in both English and Chinese
Update about and services pages with additional content
Modify footer to include remote work availability notice
2025-06-20 10:49:53 +08:00

132 lines
3.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/i18n/ui.ts
export const languages = {
en: 'English',
zh: '简体中文',
} as const;
export const defaultLang = 'en';
// 定义嵌套结构的国际化数据
const structuredUi = {
en: {
nav: {
home: 'Home',
about: 'About',
services: 'Services',
projects: 'Projects',
blog: 'Blog',
contact: 'Contact',
},
site: {
title: 'Joy Zhao - Full Stack Developer',
description: 'Full Stack Developer specializing in React, Node.js, and modern web technologies',
},
hero: {
githubLink: 'GitHub Profile',
linkedinLink: 'LinkedIn Profile',
},
footer: {
rights: 'All rights reserved',
},
project: {
tag: {
business: 'Business Project',
opensource: 'Open Source',
personal: 'Personal Product',
portfolio: 'Portfolio',
ecommerce: 'E-Commerce',
},
visit: 'Visit',
demo: 'Live Demo',
},
projects: {
title: 'My Projects',
description: 'A collection of my recent work, showcasing innovative solutions and clean code. Explore the details of each project below.',
slogan: 'Crafting elegant solutions to complex problems with clean code and innovative thinking.',
},
blog: {
slogan: 'This is where innovative thinking meets complex problems.',
},
// Projects and services content has been inlined into respective page files
// to reduce reliance on the translation system and improve maintainability
},
zh: {
nav: {
home: '首页',
about: '关于',
services: '服务',
projects: '项目',
blog: '博客',
contact: '联系',
},
site: {
title: 'Joy Zhao - 全栈开发者',
description: '专注于 React、Node.js 和现代 Web 技术的全栈开发者',
},
hero: {
githubLink: 'GitHub 主页',
linkedinLink: 'LinkedIn 主页',
},
footer: {
rights: '版权所有',
},
project: {
tag: {
business: '商业项目',
opensource: '开源项目',
personal: '个人产品',
portfolio: '作品集',
ecommerce: '电子商务',
},
visit: '访问',
demo: '在线演示',
},
projects: {
title: '我的项目',
description: '这里展示了我最近的作品集,展现了创新解决方案和整洁的代码。请浏览下方了解每个项目的详细信息。',
slogan: '用优雅的代码和创新的思维,为复杂问题打造精致的解决方案。',
},
blog: {
slogan: '这里是创新思维与复杂问题相遇的地方。',
},
// Projects and services content has been inlined into respective page files
// to reduce reliance on the translation system and improve maintainability
},
} as const;
// 创建代理对象,保持与现有代码的兼容性
function createCompatibleUi() {
// 为每种语言创建代理
const compatibleUi: Record<string, any> = {};
Object.keys(structuredUi).forEach(lang => {
compatibleUi[lang] = new Proxy({}, {
get(target, prop) {
if (typeof prop !== 'string') return undefined;
// 处理点符号键 (如 'nav.home')
const parts = prop.split('.');
let value: any = structuredUi[lang as keyof typeof structuredUi];
// 遍历嵌套结构
for (const part of parts) {
if (value && typeof value === 'object' && part in value) {
value = value[part as keyof typeof value];
} else {
return undefined; // 键不存在
}
}
return value;
}
});
});
return compatibleUi;
}
// 导出兼容的UI对象
export const ui = createCompatibleUi() as typeof structuredUi;
// 导出结构化的UI对象供将来使用
export const structuredUI = structuredUi;