Skip to content

Commit

Permalink
feat: add i18n languages
Browse files Browse the repository at this point in the history
  • Loading branch information
xiadd committed Mar 27, 2024
1 parent e0f73fb commit 68068f6
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
32 changes: 32 additions & 0 deletions static/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,45 @@ export default function Header() {
</button>
</MenuItem>
<MenuItem key="2">
<button
onClick={() => handleChangeLanguage("spanish")}
className="block w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
Español
</button>
</MenuItem>
<MenuItem key="3">
<button
onClick={() => handleChangeLanguage("russian")}
className="block w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
Русский язык
</button>
</MenuItem>
<MenuItem key="4">
<button
onClick={() => handleChangeLanguage("zh")}
className="block w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
中文
</button>
</MenuItem>
<MenuItem key="5">
<button
onClick={() => handleChangeLanguage("indonesian")}
className="block w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
Bahasa Indonesia
</button>
</MenuItem>
<MenuItem key="6">
<button
onClick={() => handleChangeLanguage("japanese")}
className="block w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
Japanese
</button>
</MenuItem>
</Menu>
}
trigger={["click"]}
Expand Down
16 changes: 16 additions & 0 deletions static/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";

import enTranslation from "./locales/en";
import indonesian from "./locales/indonesian";
import japanese from "./locales/japanese";
import russian from "./locales/russian";
import spanishTranslaction from "./locales/spanish";
import zhTranslation from "./locales/zh";

// the translations
Expand All @@ -15,6 +19,18 @@ const resources = {
zh: {
translation: zhTranslation,
},
spanish: {
translation: spanishTranslaction,
},
russian: {
translation: russian,
},
indonesian: {
translation: indonesian,
},
japanese: {
translation: japanese,
},
};

i18n
Expand Down
22 changes: 22 additions & 0 deletions static/src/locales/indonesian.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
slogan: "PasteBin lain yang berbasis Cloudflare Worker",
en: "Bahasa Inggris",
zh: "Bahasa Cina",
"zh-CN": "Bahasa Cina",
privateTip: "Apakah privat (kata sandi acak)",
expiration: "Waktu kedaluwarsa (detik)",
textShare: "Berbagi teks",
fileShare: "Berbagi file",
fileShareTip: "Seret file ke sini atau langsung tempel file atau",
viewFiles: "Lihat file",
createPaste: "Buat berbagi",
uploadError: "Gagal mengunggah: ",
uploading: "Mengunggah...",
fileSizeError: "Ukuran file tidak boleh lebih dari 25MB",
tutorial: "Panduan penggunaan",
uploadSuccess: "Berhasil diunggah",
uploadSuccessTip:
"File Anda telah berhasil diunggah, klik tombol di bawah untuk menyalin tautan",
copyLink: "Salin tautan",
copySuccess: "Berhasil menyalin",
};
22 changes: 22 additions & 0 deletions static/src/locales/japanese.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
slogan: "Cloudflare Workerに基づく別のPasteBin",
en: "英語",
zh: "中国語",
"zh-CN": "中国語",
privateTip: "プライベートかどうか(ランダムなパスワード)",
expiration: "有効期限(秒)",
textShare: "テキストを共有",
fileShare: "ファイルを共有",
fileShareTip: "ここにファイルをドラッグするか、直接ファイルを貼り付けるか",
viewFiles: "ファイルを表示",
createPaste: "共有を作成",
uploadError: "アップロードに失敗しました: ",
uploading: "アップロード中...",
fileSizeError: "ファイルサイズは25MBを超えることはできません",
tutorial: "使用チュートリアル",
uploadSuccess: "アップロード成功",
uploadSuccessTip:
"ファイルのアップロードが成功しました、以下のボタンをクリックしてリンクをコピーしてください",
copyLink: "リンクをコピー",
copySuccess: "コピー成功",
};
22 changes: 22 additions & 0 deletions static/src/locales/russian.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
slogan: "Еще один PasteBin, основанный на Cloudflare Worker",
en: "Английский",
zh: "Китайский",
"zh-CN": "Китайский",
privateTip: "Приватный (случайный пароль)",
expiration: "Время истечения (в секундах)",
textShare: "Поделиться текстом",
fileShare: "Поделиться файлом",
fileShareTip: "Перетащите файл сюда или просто вставьте файл или",
viewFiles: "Просмотреть файлы",
createPaste: "Создать общую ссылку",
uploadError: "Ошибка загрузки: ",
uploading: "Загрузка...",
fileSizeError: "Размер файла не может превышать 25MB",
tutorial: "Руководство",
uploadSuccess: "Успешная загрузка",
uploadSuccessTip:
"Ваш файл успешно загружен, нажмите на кнопку ниже, чтобы скопировать ссылку",
copyLink: "Скопировать ссылку",
copySuccess: "Копирование успешно",
};
22 changes: 22 additions & 0 deletions static/src/locales/spanish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
slogan: "Otro PasteBin basado en Cloudflare Worker",
en: "Inglés",
zh: "Chino",
"zh-CN": "Chino",
privateTip: "Es privado (contraseña aleatoria)",
expiration: "Tiempo de caducidad (segundos)",
textShare: "Compartir texto",
fileShare: "Compartir archivos",
fileShareTip: "Arrastrar el archivo aquí o pegar directamente el archivo o",
viewFiles: "Ver archivos",
createPaste: "Crear compartir",
uploadError: "Error de subida: ",
uploading: "Subiendo...",
fileSizeError: "El tamaño del archivo no puede exceder de 25MB",
tutorial: "Tutorial",
uploadSuccess: "Subida exitosa",
uploadSuccessTip:
"Su archivo se ha subido con éxito, haga clic en el botón de abajo para copiar el enlace",
copyLink: "Copiar enlace",
copySuccess: "Copia exitosa",
};

0 comments on commit 68068f6

Please sign in to comment.