diff --git a/static/js/i18n.js b/static/js/i18n.js new file mode 100644 index 0000000..3befb64 --- /dev/null +++ b/static/js/i18n.js @@ -0,0 +1,56 @@ +(function () { + var STORAGE_KEY = "taskify-lang"; + var translations = {}; + + function getLang() { + return localStorage.getItem(STORAGE_KEY) || "en"; + } + + function setLang(lang) { + localStorage.setItem(STORAGE_KEY, lang); + } + + function apply() { + document.querySelectorAll("[data-i18n]").forEach(function (el) { + var key = el.getAttribute("data-i18n"); + if (translations[key] !== undefined) el.textContent = translations[key]; + }); + document.querySelectorAll("[data-i18n-ph]").forEach(function (el) { + var key = el.getAttribute("data-i18n-ph"); + if (translations[key] !== undefined) el.placeholder = translations[key]; + }); + document.querySelectorAll("[data-i18n-val]").forEach(function (el) { + var key = el.getAttribute("data-i18n-val"); + if (translations[key] !== undefined) el.value = translations[key]; + }); + var lang = getLang(); + document.querySelectorAll(".lang-toggle").forEach(function (btn) { + btn.textContent = lang === "en" ? "EN" : "中文"; + }); + } + + function load(lang, cb) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "/static/locales/" + lang + ".json", true); + xhr.onreadystatechange = function () { + if (xhr.readyState === 4 && xhr.status === 200) { + translations = JSON.parse(xhr.responseText); + cb(); + } + }; + xhr.send(); + } + + function toggle() { + var next = getLang() === "en" ? "zh" : "en"; + setLang(next); + load(next, apply); + } + + document.addEventListener("DOMContentLoaded", function () { + load(getLang(), apply); + document.querySelectorAll(".lang-toggle").forEach(function (btn) { + btn.addEventListener("click", toggle); + }); + }); +})(); diff --git a/static/locales/en.json b/static/locales/en.json new file mode 100644 index 0000000..988b06f --- /dev/null +++ b/static/locales/en.json @@ -0,0 +1,93 @@ +{ + "nav.features": "Features", + "nav.templates": "Templates", + "nav.forTeams": "For Teams", + "nav.resources": "Resources", + "nav.pricing": "Pricing", + "nav.signup": "Sign Up", + "nav.login": "Log In", + + "hero.heading": "One app to replace them all", + "hero.placeholder": "Enter your email address", + "hero.btn": "Get Started", + + "feature.heading": "Delightfully simple and deceptively powerful task management", + "feature.desc": "30 million+ people organize billions of tasks in Todoist for their work, education, and personal life.", + "feature.1.title": "With you everywhere", + "feature.1.text": "Use Todoist's apps, extensions and widgets on any device or platform.", + "feature.1.btn": "Download apps", + "feature.2.title": "Make Todoist your", + "feature.2.text": "Customize your to-do list with filters, labels, priorities, and more.", + "feature.2.btn": "See all features", + "feature.3.title": "Productivity Method", + "feature.3.text": "Personal productivity recommendations based on your unique traits and strengths.", + "feature.3.btn": "Take the quiz", + "feature.4.title": "There's a template for tha", + "feature.4.text": "Hundreds of templates are available to get you started with whatever's on your plate.", + "feature.4.btn": "Start with templates", + "feature.5.title": "Connect with your other tool", + "feature.5.text": "Link Todoist with your calendar, voice assistant, and 30+ other tools.", + "feature.5.btn": "Install integrations", + + "achievements.heading": "A task manager you can trust for life", + "achievements.desc": "We've been building Todoist for 15 years and 169 days.", + "achievements.link": "We're in it for the long haul.", + "achievements.1.label": "App downloads", + "achievements.2.label": "Tasks completed", + "achievements.3.label": "Colleges", + "achievements.4.label": "Pro users", + + "footer.desc": "Join millions of people who organize work and life with Taskify.", + "footer.features": "FEATURES", + "footer.howItWorks": "How It Works", + "footer.forTeams": "For Teams", + "footer.pricing": "Pricing", + "footer.templates": "Templates", + "footer.resources": "RESOURCES", + "footer.downloadApps": "Download Apps", + "footer.helpCenter": "Help Center", + "footer.productivityMethods": "Productivity Methods", + "footer.referFriend": "Refer a friend", + "footer.integrations": "Integrations", + "footer.channelPartners": "Channel Partners", + "footer.developerAPI": "Developer API", + "footer.status": "Status", + "footer.company": "COMPANY", + "footer.aboutUs": "About Us", + "footer.hiring": "We are hiring!", + "footer.blog": "Blog", + "footer.press": "Press", + "footer.twist": "Twist", + "footer.security": "Security", + "footer.privacy": "Privacy", + "footer.terms": "Terms", + "footer.copyright": "© Taskify Inc.", + + "signup.signup": "Sign up", + "signup.username": "User name", + "signup.email": "Email", + "signup.password": "Password", + "signup.submit": "Sign up", + "signup.login": "Login", + "signup.loginEmail": "Enter your email", + "signup.loginPassword": "Enter password", + "signup.loginSubmit": "Login", + + "dashboard.overview": "Overview", + "dashboard.stats": "Stats", + "dashboard.projects": "Projects", + "dashboard.chat": "Chat", + "dashboard.calendar": "Calendar", + "dashboard.settings": "Settings", + "dashboard.logout": "Log out", + "dashboard.search": "Search", + "dashboard.profile": "Profile", + "dashboard.projectsTitle": "Projects", + "dashboard.thisDay": "This Day", + "dashboard.thisWeek": "This Week", + "dashboard.thisMonth": "This Month", + "dashboard.thisYear": "This Year", + "dashboard.todo": "To do", + "dashboard.inProgress": "In progress", + "dashboard.completed": "Completed" +} diff --git a/static/locales/zh.json b/static/locales/zh.json new file mode 100644 index 0000000..a8234e5 --- /dev/null +++ b/static/locales/zh.json @@ -0,0 +1,93 @@ +{ + "nav.features": "功能", + "nav.templates": "模板", + "nav.forTeams": "团队版", + "nav.resources": "资源", + "nav.pricing": "价格", + "nav.signup": "注册", + "nav.login": "登录", + + "hero.heading": "一个应用,替代所有", + "hero.placeholder": "请输入您的邮箱地址", + "hero.btn": "立即开始", + + "feature.heading": "令人愉悦的简洁,出乎意料的强大", + "feature.desc": "超过 3000 万人使用 Todoist 管理工作、学习和生活中的数十亿任务。", + "feature.1.title": "随时随地", + "feature.1.text": "在任何设备或平台上使用 Todoist 的应用、扩展和小组件。", + "feature.1.btn": "下载应用", + "feature.2.title": "打造你的 Todoist", + "feature.2.text": "使用筛选器、标签、优先级等自定义你的待办清单。", + "feature.2.btn": "查看所有功能", + "feature.3.title": "高效方法论", + "feature.3.text": "基于你的独特特质和优势提供个性化的效率建议。", + "feature.3.btn": "参加测试", + "feature.4.title": "总有一个模板适合你", + "feature.4.text": "数百个模板帮助你快速开始手头的任何事务。", + "feature.4.btn": "从模板开始", + "feature.5.title": "连接你的其他工具", + "feature.5.text": "将 Todoist 与日历、语音助手和 30 多种其他工具关联。", + "feature.5.btn": "安装集成", + + "achievements.heading": "一个值得终身信赖的任务管理器", + "achievements.desc": "我们已经构建 Todoist 超过 15 年零 169 天。", + "achievements.link": "我们会一直走下去。", + "achievements.1.label": "应用下载量", + "achievements.2.label": "已完成任务", + "achievements.3.label": "合作院校", + "achievements.4.label": "专业用户", + + "footer.desc": "加入数百万使用 Taskify 组织工作和生活的人。", + "footer.features": "功能", + "footer.howItWorks": "工作原理", + "footer.forTeams": "团队版", + "footer.pricing": "价格", + "footer.templates": "模板", + "footer.resources": "资源", + "footer.downloadApps": "下载应用", + "footer.helpCenter": "帮助中心", + "footer.productivityMethods": "效率方法", + "footer.referFriend": "推荐好友", + "footer.integrations": "集成", + "footer.channelPartners": "渠道合作伙伴", + "footer.developerAPI": "开发者 API", + "footer.status": "状态", + "footer.company": "公司", + "footer.aboutUs": "关于我们", + "footer.hiring": "我们在招聘!", + "footer.blog": "博客", + "footer.press": "媒体", + "footer.twist": "Twist", + "footer.security": "安全", + "footer.privacy": "隐私", + "footer.terms": "条款", + "footer.copyright": "© Taskify 公司", + + "signup.signup": "注册", + "signup.username": "用户名", + "signup.email": "邮箱", + "signup.password": "密码", + "signup.submit": "注册", + "signup.login": "登录", + "signup.loginEmail": "请输入邮箱", + "signup.loginPassword": "请输入密码", + "signup.loginSubmit": "登录", + + "dashboard.overview": "概览", + "dashboard.stats": "统计", + "dashboard.projects": "项目", + "dashboard.chat": "聊天", + "dashboard.calendar": "日历", + "dashboard.settings": "设置", + "dashboard.logout": "退出登录", + "dashboard.search": "搜索", + "dashboard.profile": "个人资料", + "dashboard.projectsTitle": "项目", + "dashboard.thisDay": "今天", + "dashboard.thisWeek": "本周", + "dashboard.thisMonth": "本月", + "dashboard.thisYear": "今年", + "dashboard.todo": "待办", + "dashboard.inProgress": "进行中", + "dashboard.completed": "已完成" +} diff --git a/views/index.ejs b/views/index.ejs index d4d947f..c6e6ac7 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -31,6 +31,7 @@ <%-include("../views/partials/footer.ejs") %> + \ No newline at end of file diff --git a/views/partials/achievements.ejs b/views/partials/achievements.ejs index 71bae6c..3ad028b 100644 --- a/views/partials/achievements.ejs +++ b/views/partials/achievements.ejs @@ -13,29 +13,29 @@
-

A task manager you can trust for life

-

We’ve been building Todoist for 15 years and 169 days. We're in it for the long haul.

+

A task manager you can trust for life

+

We’ve been building Todoist for 15 years and 169 days. We’re in it for the long haul.

achievement-1

300+

-

App downloads

+

App downloads

achievement-2

100+

-

Tasks completed

+

Tasks completed

achievement-3

160+

-

Colleges

+

Colleges

achievement-4

100+

-

Pro users

+

Pro users

diff --git a/views/partials/feature.ejs b/views/partials/feature.ejs index d4aacf2..9cf3d84 100644 --- a/views/partials/feature.ejs +++ b/views/partials/feature.ejs @@ -12,43 +12,43 @@
-

Delightfully simple and deceptively powerful task +

Delightfully simple and deceptively powerful task management

-

30 million+ people organize billions of tasks in Todoist for their work, education, and personal life.

+

30 million+ people organize billions of tasks in Todoist for their work, education, and personal life.

feature1 -

With you everywhere

-

Use Todoist’s apps, extensions and widgets on any device or platform.

- Download apps +

With you everywhere

+

Use Todoist’s apps, extensions and widgets on any device or platform.

+ Download apps
feature2 -

Make Todoist your

-

Customize your to-do list with filters, labels, priorities, and more.

- See all features +

Make Todoist your

+

Customize your to-do list with filters, labels, priorities, and more.

+ See all features
feature3 -

Productivity Method

-

Personal productivity recommendations based on your unique traits and strengths.

- Take the quiz +

Productivity Method

+

Personal productivity recommendations based on your unique traits and strengths.

+ Take the quiz
feature4 -

There’s a template for tha

-

Hundreds of templates are available to get you started with whatever’s on your plate.

- Start with templates +

There’s a template for tha

+

Hundreds of templates are available to get you started with whatever’s on your plate.

+ Start with templates
feature5 -

Connect with your other tool

-

Link Todoist with your calendar, voice assistant, and 30+ other tools.

- Install integrations +

Connect with your other tool

+

Link Todoist with your calendar, voice assistant, and 30+ other tools.

+ Install integrations
diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs index 33a9824..54d6116 100644 --- a/views/partials/footer.ejs +++ b/views/partials/footer.ejs @@ -17,7 +17,7 @@