Files
zhaoguiyang.site/src/i18n/translations.ts

161 lines
4.6 KiB
TypeScript

export const languages = {
en: 'English',
zh: '简体中文',
} as const;
export const defaultLang = 'en';
export const translations = {
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: {
greeting: "Hello, I'm",
viewProjects: 'About Me',
contactMe: 'Contact Me',
lookingForJob: 'Looking for a Frontend/TS Full-stack Engineer (Remote)? Contact me!',
digitalNomad: 'Exploring the freelance journey, striving to become a digital nomad',
contactInfo: 'Contact Me',
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.',
backToList: 'Back to Blog',
},
services: {
title: 'What I Do',
viewAll: 'Learn More',
},
about: {
title: 'About Me',
sectionTitle: 'About Me',
learnMore: 'Learn More About Me',
toolbox: 'My Toolbox',
},
},
zh: {
nav: {
home: '首页',
about: '关于',
services: '服务',
projects: '项目',
blog: '博客',
contact: '联系',
},
site: {
title: 'Joy Zhao - 全栈开发者',
description: '专注于 React、Node.js 和现代 Web 技术的全栈开发者',
},
hero: {
greeting: '你好,我是',
viewProjects: '关于我',
contactMe: '联系我',
lookingForJob: '正在寻找前端/TS 全栈工程师(远程)?联系我!',
digitalNomad: '探索自由职业道路,努力成为数字游民',
contactInfo: '联系我',
githubLink: 'GitHub 主页',
linkedinLink: 'LinkedIn 主页',
},
footer: {
rights: '版权所有',
},
project: {
tag: {
business: '商业项目',
opensource: '开源项目',
personal: '个人项目',
portfolio: '作品集',
ecommerce: '电子商务',
},
visit: '访问',
demo: '在线演示',
},
projects: {
title: '我的项目',
description: '这里展示了我最近的作品集,展现了创新解决方案和整洁的代码。请浏览下方了解每个项目的详细信息。',
slogan: '用优雅的代码和创新的思维,为复杂问题打造精致的解决方案。',
},
blog: {
slogan: '这里是创新思维与复杂问题相遇的地方。',
backToList: '返回博客列表',
},
services: {
title: '我能做什么',
viewAll: '了解更多',
},
about: {
title: '关于我',
sectionTitle: '关于我',
learnMore: '了解更多',
toolbox: '我的工具箱',
},
},
} as const;
/**
* Generate flattened translations for better performance
* This creates a flat object with dot notation keys
*/
export function generateFlatTranslations() {
const flattenedTranslations: Record<string, Record<string, string>> = {};
// Initialize for each language
Object.keys(translations).forEach(lang => {
flattenedTranslations[lang] = {};
});
// Recursive function to flatten nested objects
function flatten(obj: any, lang: string, prefix = '') {
for (const key in obj) {
const value = obj[key];
const newKey = prefix ? `${prefix}.${key}` : key;
if (typeof value === 'object' && value !== null) {
flatten(value, lang, newKey);
} else {
flattenedTranslations[lang][newKey] = value;
}
}
}
// Process each language
Object.keys(translations).forEach(lang => {
flatten(translations[lang as keyof typeof translations], lang);
});
return flattenedTranslations;
}
/**
* Flattened translations for faster lookups
*/
export const flatTranslations = generateFlatTranslations();