1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-13 13:50:27 +05:30

Localize feed TimeAgo.

Partially fixes #554.
This commit is contained in:
FireMaskterK 2021-10-27 01:59:03 +01:00
parent e19fbca300
commit a5b5b94b43
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
2 changed files with 13 additions and 0 deletions

View File

@ -63,6 +63,13 @@ export default {
(async function() { (async function() {
const locale = App.getPreferenceString("hl", App.defaultLangage); const locale = App.getPreferenceString("hl", App.defaultLangage);
if (locale !== App.TimeAgoConfig.locale) {
const localeTime = await import("javascript-time-ago/locale/" + locale + ".json").then(
module => module.default,
);
App.TimeAgo.addLocale(localeTime);
App.TimeAgoConfig.locale = locale;
}
if (window.i18n.global.locale.value !== locale) { if (window.i18n.global.locale.value !== locale) {
if (!window.i18n.global.availableLocales.includes(locale)) { if (!window.i18n.global.availableLocales.includes(locale)) {
const messages = await import("@/locales/" + locale + ".json").then(module => module.default); const messages = await import("@/locales/" + locale + ".json").then(module => module.default);

View File

@ -225,6 +225,12 @@ const mixin = {
return "en"; return "en";
}, },
}, },
data() {
return {
TimeAgo: TimeAgo,
TimeAgoConfig: timeAgo,
};
},
}; };
const i18n = createI18n({ const i18n = createI18n({