Move "toLocalNumber" to utils.

This commit is contained in:
N-Pex 2025-05-09 14:42:37 +02:00
parent 674eaa5eeb
commit ce81fdc91e
5 changed files with 75 additions and 91 deletions

View file

@ -1,8 +1,7 @@
import QuickReactions from "./QuickReactions.vue";
import * as linkify from 'linkifyjs';
import linkifyHtml from 'linkify-html';
import utils from "../../plugins/utils"
import util from "../../plugins/utils";
import utils from "../../plugins/utils";
import Hammer from "hammerjs";
linkify.options.defaults.className = "link";
@ -140,7 +139,7 @@ export default {
if (this.inReplyToEvent && (this.inReplyToEvent.isThreadRoot || this.inReplyToEvent.isMxThread)) {
const children = this.timelineSet.relations
.getAllChildEventsForEvent(this.inReplyToEvent.getId())
.filter((e) => util.downloadableTypes().includes(e.getContent().msgtype));
.filter((e) => utils.downloadableTypes().includes(e.getContent().msgtype));
return this.$t("message.sent_media", { count: children.length });
}
const content = this.event.getContent();
@ -311,29 +310,7 @@ export default {
} else {
s = this.$t("global.time.days", Math.round(ti / 60 / 60 / 24));
}
return this.toLocalNumbers(s);
},
/**
* Possibly convert numerals to local representation (currently only for "bo" locale)
* @param str String in which to convert numerals [0-9]
* @returns converted string
*/
toLocalNumbers(str) {
if (this.$i18n.locale == "bo") {
// Translate to tibetan numerals
let result = "";
for (let i = 0; i < str.length; i++) {
let c = str.charCodeAt(i);
if (c >= 48 && c <= 57) {
result += String.fromCharCode(c + 0x0f20 - 48);
} else {
result += String.fromCharCode(c);
}
}
return result;
}
return str;
return utils.toLocalNumbers(s);
},
linkify(text) {