From 0d8039eddcf77f3b32059b50a9f6a73c36ad2cad Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 21 Mar 2024 10:53:05 +0000 Subject: [PATCH 1/3] Add copyright to i18n files --- src/i18n/i18n.js | 18 ++++++++++++++++++ src/i18n/i18nChangeLanguage.js | 19 +++++++++++++++++++ src/i18n/translations/ar.js | 18 ++++++++++++++++++ src/i18n/translations/bn.js | 18 ++++++++++++++++++ src/i18n/translations/da.js | 18 ++++++++++++++++++ src/i18n/translations/de.js | 18 ++++++++++++++++++ src/i18n/translations/emoji.js | 18 ++++++++++++++++++ src/i18n/translations/en.js | 18 ++++++++++++++++++ src/i18n/translations/es.js | 18 ++++++++++++++++++ src/i18n/translations/fa.js | 18 ++++++++++++++++++ src/i18n/translations/fi.js | 18 ++++++++++++++++++ src/i18n/translations/fr.js | 18 ++++++++++++++++++ src/i18n/translations/hy.js | 18 ++++++++++++++++++ src/i18n/translations/it.js | 18 ++++++++++++++++++ src/i18n/translations/ko.js | 18 ++++++++++++++++++ src/i18n/translations/nb.js | 18 ++++++++++++++++++ src/i18n/translations/nn.js | 18 ++++++++++++++++++ src/i18n/translations/ro.js | 18 ++++++++++++++++++ src/i18n/translations/sv.js | 18 ++++++++++++++++++ src/i18n/translations/th.js | 18 ++++++++++++++++++ src/i18n/translations/translations.js | 18 ++++++++++++++++++ src/i18n/translations/ur.js | 18 ++++++++++++++++++ src/i18n/translations/zh.js | 18 ++++++++++++++++++ 23 files changed, 415 insertions(+) diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js index 015cfaf7..6adcd5f0 100644 --- a/src/i18n/i18n.js +++ b/src/i18n/i18n.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ import translations from './translations/translations.js'; window.ListSupportedLanugages = () => Object.keys(translations).map(lang => translations[lang]); diff --git a/src/i18n/i18nChangeLanguage.js b/src/i18n/i18nChangeLanguage.js index 5f4a8dff..e3482daf 100644 --- a/src/i18n/i18nChangeLanguage.js +++ b/src/i18n/i18nChangeLanguage.js @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + function ChangeLanguage(lang) { window.locale = lang; window.mutate_user_preferences({ diff --git a/src/i18n/translations/ar.js b/src/i18n/translations/ar.js index 41429638..ea51c9d4 100644 --- a/src/i18n/translations/ar.js +++ b/src/i18n/translations/ar.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const ar = { name: "العربية", code: "ar", diff --git a/src/i18n/translations/bn.js b/src/i18n/translations/bn.js index bd244b9e..2bd82522 100644 --- a/src/i18n/translations/bn.js +++ b/src/i18n/translations/bn.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const bn = { name: "বাংলা", code: "bn", diff --git a/src/i18n/translations/da.js b/src/i18n/translations/da.js index 3aea0d48..ca72769e 100644 --- a/src/i18n/translations/da.js +++ b/src/i18n/translations/da.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const da = { name: "Dansk", code: "da", diff --git a/src/i18n/translations/de.js b/src/i18n/translations/de.js index 6b3ba66e..7a750370 100644 --- a/src/i18n/translations/de.js +++ b/src/i18n/translations/de.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const de = { name: "Deutsch", code: "de", diff --git a/src/i18n/translations/emoji.js b/src/i18n/translations/emoji.js index ebe7d9a3..3add582a 100644 --- a/src/i18n/translations/emoji.js +++ b/src/i18n/translations/emoji.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const emoji = { name: "🌍", code: "emoji", diff --git a/src/i18n/translations/en.js b/src/i18n/translations/en.js index 0c02478c..31555f3d 100644 --- a/src/i18n/translations/en.js +++ b/src/i18n/translations/en.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const en = { name: "English", code: "en", diff --git a/src/i18n/translations/es.js b/src/i18n/translations/es.js index 261f555f..82005c4e 100644 --- a/src/i18n/translations/es.js +++ b/src/i18n/translations/es.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const es = { name: "Español", code: "es", diff --git a/src/i18n/translations/fa.js b/src/i18n/translations/fa.js index 8d88c785..4ccffa2d 100644 --- a/src/i18n/translations/fa.js +++ b/src/i18n/translations/fa.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const fa = { name: "فارسی", code: "fa", diff --git a/src/i18n/translations/fi.js b/src/i18n/translations/fi.js index 6f389bcf..d43d0753 100644 --- a/src/i18n/translations/fi.js +++ b/src/i18n/translations/fi.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const fi = { name: "Suomi", code: "fi", diff --git a/src/i18n/translations/fr.js b/src/i18n/translations/fr.js index ecf54465..1ce604af 100644 --- a/src/i18n/translations/fr.js +++ b/src/i18n/translations/fr.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const fr = { name: "Français", code: "fr", diff --git a/src/i18n/translations/hy.js b/src/i18n/translations/hy.js index 8a55a73a..1388753b 100644 --- a/src/i18n/translations/hy.js +++ b/src/i18n/translations/hy.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const hy = { name: "Հայերեն", code: "hy", diff --git a/src/i18n/translations/it.js b/src/i18n/translations/it.js index 6d327c23..c967671b 100644 --- a/src/i18n/translations/it.js +++ b/src/i18n/translations/it.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const it = { name: "Italiano", code: "it", diff --git a/src/i18n/translations/ko.js b/src/i18n/translations/ko.js index 9c8d487b..517b264e 100644 --- a/src/i18n/translations/ko.js +++ b/src/i18n/translations/ko.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const ko = { name: "한국어", code: "ko", diff --git a/src/i18n/translations/nb.js b/src/i18n/translations/nb.js index dc173ed2..ede9362b 100644 --- a/src/i18n/translations/nb.js +++ b/src/i18n/translations/nb.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const nb = { name: "Norsk Bokmål", code: "nb", diff --git a/src/i18n/translations/nn.js b/src/i18n/translations/nn.js index 0c2169ec..a4298e5b 100644 --- a/src/i18n/translations/nn.js +++ b/src/i18n/translations/nn.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const nn = { name: "Norsk Nynorsk", code: "nn", diff --git a/src/i18n/translations/ro.js b/src/i18n/translations/ro.js index 25d14f35..14adabba 100644 --- a/src/i18n/translations/ro.js +++ b/src/i18n/translations/ro.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const ro = { name: "Română", code: "ro", diff --git a/src/i18n/translations/sv.js b/src/i18n/translations/sv.js index 3e8b8a66..30f3c700 100644 --- a/src/i18n/translations/sv.js +++ b/src/i18n/translations/sv.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const sv = { name: "Svenska", code: "sv", diff --git a/src/i18n/translations/th.js b/src/i18n/translations/th.js index 3dd2c432..f369143f 100644 --- a/src/i18n/translations/th.js +++ b/src/i18n/translations/th.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const th = { name: "ไทย", code: "th", diff --git a/src/i18n/translations/translations.js b/src/i18n/translations/translations.js index 0610e484..b2eec36e 100644 --- a/src/i18n/translations/translations.js +++ b/src/i18n/translations/translations.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ import ar from './ar.js'; import bn from './bn.js' import da from './da.js'; diff --git a/src/i18n/translations/ur.js b/src/i18n/translations/ur.js index f2a0c565..cfa51332 100644 --- a/src/i18n/translations/ur.js +++ b/src/i18n/translations/ur.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const ur = { name: "اردو", code: "ur", diff --git a/src/i18n/translations/zh.js b/src/i18n/translations/zh.js index 76770853..7066a4d0 100644 --- a/src/i18n/translations/zh.js +++ b/src/i18n/translations/zh.js @@ -1,3 +1,21 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ const zh = { name: "中文", code: "zh", From afd733024bf6cc15df2766be7c8dbf88fc30416c Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 20 Mar 2024 11:21:54 +0000 Subject: [PATCH 2/3] Fix some i18n-related typos --- src/UI/UIDesktop.js | 6 +++--- src/i18n/i18n.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index ccb2121e..936ba9b9 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -1146,9 +1146,9 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ } // ------------------------------------------- - // Load avaialble languages + // Load available languages // ------------------------------------------- - const supoprtedLanguagesItems = ListSupportedLanugages().map(lang => { + const supportedLanguagesItems = ListSupportedLanguages().map(lang => { return { html: lang.name, icon: window.locale === lang.code ? '✓' : '', @@ -1198,7 +1198,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ //-------------------------------------------------- { html: i18n('change_language'), - items: supoprtedLanguagesItems + items: supportedLanguagesItems }, //-------------------------------------------------- // Contact Us diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js index 6adcd5f0..14b46873 100644 --- a/src/i18n/i18n.js +++ b/src/i18n/i18n.js @@ -18,7 +18,7 @@ */ import translations from './translations/translations.js'; -window.ListSupportedLanugages = () => Object.keys(translations).map(lang => translations[lang]); +window.ListSupportedLanguages = () => Object.keys(translations).map(lang => translations[lang]); window.i18n = function (key, replacements = [], encode_html = true) { if(typeof replacements === 'boolean' && encode_html === undefined){ From 3f27608850b3a5d8adc7fad37f766e774bd58502 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 20 Mar 2024 12:00:56 +0000 Subject: [PATCH 3/3] Add a script to check our translation files are valid Checks the following: - Translation files are valid JS - Each translation file is registered in translations.js - Each translation's code matches its name - Translation dictionaries only contain keys that exist in the English translation. --- .github/workflows/check-translations.yml | 28 ++++++++ package.json | 3 +- tools/check-translations.js | 83 ++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-translations.yml create mode 100644 tools/check-translations.js diff --git a/.github/workflows/check-translations.yml b/.github/workflows/check-translations.yml new file mode 100644 index 00000000..364328e9 --- /dev/null +++ b/.github/workflows/check-translations.yml @@ -0,0 +1,28 @@ +# This workflow runs the tools/check-translations.js script to make sure that the translation data is valid. + +name: Check Translations + +env: + NODE_VERSION: 21.x + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + cache-dependency-path: ./package-lock.json + - run: npm ci + - run: npm run check-translations \ No newline at end of file diff --git a/package.json b/package.json index dd6871ae..f76793fa 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon --exec \"node dev-server.js\" ", - "build": "node ./build.js" + "build": "node ./build.js", + "check-translations": "node tools/check-translations.js" }, "nodemonConfig": { "ext": "js, json, mjs, jsx, svg, css", diff --git a/tools/check-translations.js b/tools/check-translations.js new file mode 100644 index 00000000..b718ec63 --- /dev/null +++ b/tools/check-translations.js @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2024 Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +import translations from '../src/i18n/translations/translations.js'; +import fs from 'fs'; + +let hadError = false; +function reportError(message) { + hadError = true; + process.stderr.write(`❌ ${message}\n`); +} + +// Check that each translation file is recorded in `translations` +async function checkTranslationRegistrations() { + const files = await fs.promises.readdir('./src/i18n/translations'); + for (const fileName of files) { + if (!fileName.endsWith('.js')) continue; + const translationName = fileName.substring(0, fileName.length - 3); + if (translationName === 'translations') continue; + + const translation = translations[translationName]; + if (!translation) { + reportError(`Translation '${translationName}' is not listed in translations.js, please add it!`); + continue; + } + + if (!translation.name) { + reportError(`Translation '${translationName}' is missing a name!`); + } + if (!translation.code) { + reportError(`Translation '${translationName}' is missing a code!`); + } else if (translation.code !== translationName) { + reportError(`Translation '${translationName}' has code '${translation.code}', which should be '${translationName}'!`); + } + if (typeof translation.dictionary !== 'object') { + reportError(`Translation '${translationName}' is missing a translations dictionary! Should be an object.`); + } + } +} + +function checkTranslationKeys() { + const enDictionary = translations.en.dictionary; + + for (const translation of Object.values(translations)) { + // We compare against the en translation, so checking it doesn't make sense. + if (translation.code === 'en') continue; + + // If the dictionary is missing, we already reported that in checkTranslationRegistrations(). + if (typeof translation.dictionary !== "object") continue; + + for (const [key, value] of Object.entries(translation.dictionary)) { + if (!enDictionary[key]) { + reportError(`Translation '${translation.code}' has key '${key}' that doesn't exist in 'en'!`); + } + } + } +} + +await checkTranslationRegistrations(); +checkTranslationKeys(); + +if (hadError) { + process.stdout.write('Errors were found in translation files.\n'); + process.exit(1); +} + +process.stdout.write('✅ Translations appear valid.\n'); +process.exit(0); \ No newline at end of file