Merge remote-tracking branch 'upstream/master' into improve-translatables

This commit is contained in:
Ivan Bratović 2021-11-29 12:51:08 +01:00
commit d95258e7db
10 changed files with 101 additions and 86 deletions

View File

@ -7,12 +7,12 @@ class Pushover extends NotificationProvider {
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully."; let okMsg = "Sent Successfully.";
let pushoverlink = "https://api.pushover.net/1/messages.json" let pushoverlink = "https://api.pushover.net/1/messages.json";
try { try {
if (heartbeatJSON == null) { if (heartbeatJSON == null) {
let data = { let data = {
"message": "<b>Uptime Kuma Pushover testing successful.</b>", "message": msg,
"user": notification.pushoveruserkey, "user": notification.pushoveruserkey,
"token": notification.pushoverapptoken, "token": notification.pushoverapptoken,
"sound": notification.pushoversounds, "sound": notification.pushoversounds,
@ -21,8 +21,8 @@ class Pushover extends NotificationProvider {
"retry": "30", "retry": "30",
"expire": "3600", "expire": "3600",
"html": 1, "html": 1,
} };
await axios.post(pushoverlink, data) await axios.post(pushoverlink, data);
return okMsg; return okMsg;
} }
@ -36,11 +36,11 @@ class Pushover extends NotificationProvider {
"retry": "30", "retry": "30",
"expire": "3600", "expire": "3600",
"html": 1, "html": 1,
} };
await axios.post(pushoverlink, data) await axios.post(pushoverlink, data);
return okMsg; return okMsg;
} catch (error) { } catch (error) {
this.throwGeneralAxiosError(error) this.throwGeneralAxiosError(error);
} }
} }

View File

@ -4,7 +4,7 @@
<label for="language" class="form-label"> <label for="language" class="form-label">
{{ $t("Language") }} {{ $t("Language") }}
</label> </label>
<select id="language" v-model="$i18n.locale" class="form-select"> <select id="language" v-model="$root.language" class="form-select">
<option <option
v-for="(lang, i) in $i18n.availableLocales" v-for="(lang, i) in $i18n.availableLocales"
:key="`Lang${i}`" :key="`Lang${i}`"
@ -116,14 +116,8 @@
</template> </template>
<script> <script>
import { setPageLocale } from "../../util-frontend";
export default { export default {
watch: {
"$i18n.locale"() {
localStorage.locale = this.$i18n.locale;
setPageLocale();
},
},
}; };
</script> </script>

View File

@ -122,6 +122,7 @@
<HiddenInput <HiddenInput
id="steamAPIKey" id="steamAPIKey"
v-model="settings.steamAPIKey" v-model="settings.steamAPIKey"
autocomplete="one-time-code"
/> />
<div class="form-text"> <div class="form-text">
{{ $t("steamApiKeyDescription") }} {{ $t("steamApiKeyDescription") }}

View File

@ -1,62 +1,45 @@
import { createI18n } from "vue-i18n/index"; import { createI18n } from "vue-i18n/index";
import daDK from "./languages/da-DK";
import deDE from "./languages/de-DE";
import en from "./languages/en"; import en from "./languages/en";
import esEs from "./languages/es-ES";
import etEE from "./languages/et-EE";
import fa from "./languages/fa";
import frFR from "./languages/fr-FR";
import hu from "./languages/hu";
import hrHR from "./languages/hr-HR";
import itIT from "./languages/it-IT";
import idID from "./languages/id-ID";
import ja from "./languages/ja";
import koKR from "./languages/ko-KR";
import nlNL from "./languages/nl-NL";
import nbNO from "./languages/nb-NO";
import pl from "./languages/pl";
import ptBR from "./languages/pt-BR";
import bgBG from "./languages/bg-BG";
import ruRU from "./languages/ru-RU";
import sr from "./languages/sr";
import srLatn from "./languages/sr-latn";
import svSE from "./languages/sv-SE";
import trTR from "./languages/tr-TR";
import vi from "./languages/vi";
import zhCN from "./languages/zh-CN";
import zhHK from "./languages/zh-HK";
import zhTW from "./languages/zh-TW";
const languageList = { const languageList = {
en, "zh-HK": "繁體中文 (香港)",
"zh-HK": zhHK, "bg-BG": "Български",
"bg-BG": bgBG, "de-DE": "Deutsch (Deutschland)",
"de-DE": deDE, "nl-NL": "Nederlands",
"nl-NL": nlNL, "nb-NO": "Norsk",
"nb-NO": nbNO, "es-ES": "Español",
"es-ES": esEs, "fa": "Farsi",
"fa": fa, "pt-BR": "Português (Brasileiro)",
"pt-BR": ptBR, "fr-FR": "Français (France)",
"fr-FR": frFR, "hu": "Magyar",
"hu": hu, "hr-HR": "Hrvatski",
"hr-HR": hrHR, "it-IT": "Italiano (Italian)",
"it-IT": itIT, "id-ID": "Bahasa Indonesia (Indonesian)",
"id-ID" : idID, "ja": "日本語",
"ja": ja, "da-DK": "Danish (Danmark)",
"da-DK": daDK, "sr": "Српски",
"sr": sr, "sr-latn": "Srpski",
"sr-latn": srLatn, "sv-SE": "Svenska",
"sv-SE": svSE, "tr-TR": "Türkçe",
"tr-TR": trTR, "ko-KR": "한국어",
"ko-KR": koKR, "ru-RU": "Русский",
"ru-RU": ruRU, "zh-CN": "简体中文",
"zh-CN": zhCN, "pl": "Polski",
"pl": pl, "et-EE": "eesti",
"et-EE": etEE, "vi": "Vietnamese",
"vi": vi, "zh-TW": "繁體中文 (台灣)"
"zh-TW": zhTW
}; };
let messages = {
en,
};
for (let lang in languageList) {
messages[lang] = {
languageName: languageList[lang]
};
}
const rtlLangs = ["fa"]; const rtlLangs = ["fa"];
export const currentLocale = () => localStorage.locale export const currentLocale = () => localStorage.locale
@ -73,5 +56,5 @@ export const i18n = createI18n({
fallbackLocale: "en", fallbackLocale: "en",
silentFallbackWarn: true, silentFallbackWarn: true,
silentTranslationWarn: true, silentTranslationWarn: true,
messages: languageList, messages: messages,
}); });

View File

@ -5,10 +5,7 @@
3. Run `npm run update-language-files`. You can also use this command to check if there are new strings to translate for your language. 3. Run `npm run update-language-files`. You can also use this command to check if there are new strings to translate for your language.
4. Your language file should be filled in. You can translate now. 4. Your language file should be filled in. You can translate now.
5. Translate `src/components/settings/Security.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`). 5. Translate `src/components/settings/Security.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`).
6. Import your language file in `src/i18n.js` and add it to `languageList` constant. 6. Add it into `languageList` constant.
7. Make a [pull request](https://github.com/louislam/uptime-kuma/pulls) when you have done. 7. Make a [pull request](https://github.com/louislam/uptime-kuma/pulls) when you have done.
One of good examples:
https://github.com/louislam/uptime-kuma/pull/316/files
If you do not have programming skills, let me know in [Issues section](https://github.com/louislam/uptime-kuma/issues). I will assist you. 😏 If you do not have programming skills, let me know in [Issues section](https://github.com/louislam/uptime-kuma/issues). I will assist you. 😏

View File

@ -89,7 +89,7 @@ export default {
Timezone: "Часова зона", Timezone: "Часова зона",
"Search Engine Visibility": "Видимост за търсачки", "Search Engine Visibility": "Видимост за търсачки",
"Allow indexing": "Разреши индексиране", "Allow indexing": "Разреши индексиране",
"Discourage search engines from indexing site": "Обезкуражи индексирането на сайта от търсачките", "Discourage search engines from indexing site": "Не позволявай на търсачките да индексират този сайт",
"Change Password": "Промени парола", "Change Password": "Промени парола",
"Current Password": "Текуща парола", "Current Password": "Текуща парола",
"New Password": "Нова парола", "New Password": "Нова парола",
@ -307,4 +307,5 @@ export default {
PasswordsDoNotMatch: "Паролите не съвпадат.", PasswordsDoNotMatch: "Паролите не съвпадат.",
"Current User": "Текущ потребител", "Current User": "Текущ потребител",
recent: "Скорошни", recent: "Скорошни",
shrinkDatabaseDescription: "Инициира \"VACUUM\" за \"SQLite\" база данни. Ако Вашата база данни е създадена след версия 1.10.0, \"AUTO_VACUUM\" функцията е активна и това действие не нужно.",
}; };

View File

@ -12,6 +12,7 @@ import mobile from "./mixins/mobile";
import publicMixin from "./mixins/public"; import publicMixin from "./mixins/public";
import socket from "./mixins/socket"; import socket from "./mixins/socket";
import theme from "./mixins/theme"; import theme from "./mixins/theme";
import lang from "./mixins/lang";
import { router } from "./router"; import { router } from "./router";
import { appName } from "./util.ts"; import { appName } from "./util.ts";
@ -22,6 +23,7 @@ const app = createApp({
mobile, mobile,
datetime, datetime,
publicMixin, publicMixin,
lang,
], ],
data() { data() {
return { return {

33
src/mixins/lang.js Normal file
View File

@ -0,0 +1,33 @@
import { currentLocale } from "../i18n";
import { setPageLocale } from "../util-frontend";
const langModules = import.meta.glob("../languages/*.js");
export default {
data() {
return {
language: currentLocale(),
};
},
async created() {
if (this.language !== "en") {
await this.changeLang(this.language);
}
},
watch: {
async language(lang) {
await this.changeLang(lang);
},
},
methods: {
async changeLang(lang) {
let message = (await langModules["../languages/" + lang + ".js"]()).default;
this.$i18n.setLocaleMessage(lang, message);
this.$i18n.locale = lang;
localStorage.locale = lang;
setPageLocale();
}
}
};

View File

@ -44,8 +44,20 @@ export default {
settings: {}, settings: {},
settingsLoaded: false, settingsLoaded: false,
};
},
subMenus: { computed: {
currentPage() {
let pathEnd = useRoute().path.split("/").at(-1);
if (pathEnd == "settings" || pathEnd == null) {
return "general";
}
return pathEnd;
},
subMenus() {
return {
general: { general: {
title: this.$t("General"), title: this.$t("General"),
}, },
@ -67,18 +79,8 @@ export default {
about: { about: {
title: this.$t("About"), title: this.$t("About"),
}, },
},
}; };
}, },
computed: {
currentPage() {
let pathEnd = useRoute().path.split("/").at(-1);
if (pathEnd == "settings" || pathEnd == null) {
return "general";
}
return pathEnd;
},
}, },
mounted() { mounted() {

View File

@ -83,6 +83,7 @@ describe("Init", () => {
}); });
// Settings Page // Settings Page
/*
describe("Settings", () => { describe("Settings", () => {
beforeEach(async () => { beforeEach(async () => {
await page.goto(baseURL + "/settings"); await page.goto(baseURL + "/settings");
@ -261,6 +262,7 @@ describe("Init", () => {
// }, { timeout: 3000 }); // }, { timeout: 3000 });
// }); // });
}); });
*/
/* /*
* TODO * TODO