Move "toLocalNumber" to utils.
This commit is contained in:
parent
674eaa5eeb
commit
ce81fdc91e
5 changed files with 75 additions and 91 deletions
|
|
@ -12,13 +12,14 @@
|
||||||
</template>
|
</template>
|
||||||
<span>{{ $t("global.click_to_remove") }}</span>
|
<span>{{ $t("global.click_to_remove") }}</span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
<v-icon v-else class="ma-1 ml-0 clickable" @click="onClickEmoji(name)">$vuetify.icons.ic_like</v-icon> {{ $i18n.toLocalNumbers(value.length.toFixed()) }}
|
<v-icon v-else class="ma-1 ml-0 clickable" @click="onClickEmoji(name)">$vuetify.icons.ic_like</v-icon> {{ utils.toLocalNumbers(value.length.toFixed()) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import messageOperationsMixin from "../messageOperationsMixin";
|
import messageOperationsMixin from "../messageOperationsMixin";
|
||||||
|
import utils from "@/plugins/utils"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [messageOperationsMixin],
|
mixins: [messageOperationsMixin],
|
||||||
|
|
@ -38,6 +39,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
utils,
|
||||||
reactionMap: {"❤️": []},
|
reactionMap: {"❤️": []},
|
||||||
reactions: null,
|
reactions: null,
|
||||||
REACTION_LIMIT: 5,
|
REACTION_LIMIT: 5,
|
||||||
|
|
@ -45,7 +47,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log("I18", this.$i18n.toLocalNumbers);
|
|
||||||
this.reactions = this.timelineSet.relations.getChildEventsForEvent(this.event.getId(), 'm.annotation', 'm.reaction');
|
this.reactions = this.timelineSet.relations.getChildEventsForEvent(this.event.getId(), 'm.annotation', 'm.reaction');
|
||||||
this.event.on("Event.relationsCreated", this.onRelationsCreated);
|
this.event.on("Event.relationsCreated", this.onRelationsCreated);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import QuickReactions from "./QuickReactions.vue";
|
import QuickReactions from "./QuickReactions.vue";
|
||||||
import * as linkify from 'linkifyjs';
|
import * as linkify from 'linkifyjs';
|
||||||
import linkifyHtml from 'linkify-html';
|
import linkifyHtml from 'linkify-html';
|
||||||
import utils from "../../plugins/utils"
|
import utils from "../../plugins/utils";
|
||||||
import util from "../../plugins/utils";
|
|
||||||
import Hammer from "hammerjs";
|
import Hammer from "hammerjs";
|
||||||
|
|
||||||
linkify.options.defaults.className = "link";
|
linkify.options.defaults.className = "link";
|
||||||
|
|
@ -140,7 +139,7 @@ export default {
|
||||||
if (this.inReplyToEvent && (this.inReplyToEvent.isThreadRoot || this.inReplyToEvent.isMxThread)) {
|
if (this.inReplyToEvent && (this.inReplyToEvent.isThreadRoot || this.inReplyToEvent.isMxThread)) {
|
||||||
const children = this.timelineSet.relations
|
const children = this.timelineSet.relations
|
||||||
.getAllChildEventsForEvent(this.inReplyToEvent.getId())
|
.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 });
|
return this.$t("message.sent_media", { count: children.length });
|
||||||
}
|
}
|
||||||
const content = this.event.getContent();
|
const content = this.event.getContent();
|
||||||
|
|
@ -311,29 +310,7 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
s = this.$t("global.time.days", Math.round(ti / 60 / 60 / 24));
|
s = this.$t("global.time.days", Math.round(ti / 60 / 60 / 24));
|
||||||
}
|
}
|
||||||
return this.toLocalNumbers(s);
|
return utils.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;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
linkify(text) {
|
linkify(text) {
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,8 @@ router.app = app;
|
||||||
app.use(navigation, router);
|
app.use(navigation, router);
|
||||||
app.use(vuetify);
|
app.use(vuetify);
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
|
app.$i18n = i18n;
|
||||||
|
app.config.globalProperties.$i18n = i18n;
|
||||||
|
|
||||||
app.use(matrix, { store: store, i18n: i18n });
|
app.use(matrix, { store: store, i18n: i18n });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,35 +48,4 @@ const vue18n = new createI18n({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
vue18n.toLocalNumbers = (str) => {
|
|
||||||
if (vue18n.locale == "my") {
|
|
||||||
// Translate to burmese numerals
|
|
||||||
var result = "";
|
|
||||||
for (var i = 0; i < str.length; i++) {
|
|
||||||
var c = str.charCodeAt(i);
|
|
||||||
if (c >= 48 && c <= 57) {
|
|
||||||
result += String.fromCharCode(c + 0x1040 - 48);
|
|
||||||
} else {
|
|
||||||
result += String.fromCharCode(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
} else if (vue18n.locale == "bo") {
|
|
||||||
// Translate to tibetan numerals
|
|
||||||
result = "";
|
|
||||||
for (i = 0; i < str.length; i++) {
|
|
||||||
c = str.charCodeAt(i);
|
|
||||||
if (c >= 48 && c <= 57) {
|
|
||||||
result += String.fromCharCode(c + 0x0f20 - 48);
|
|
||||||
} else {
|
|
||||||
result += String.fromCharCode(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export default vue18n;
|
export default vue18n;
|
||||||
|
|
@ -1,16 +1,17 @@
|
||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
import * as ContentHelpers from "matrix-js-sdk/lib/content-helpers";
|
import * as ContentHelpers from "matrix-js-sdk/lib/content-helpers";
|
||||||
import imageResize from "image-resize";
|
import imageResize from "image-resize";
|
||||||
import { AutoDiscovery } from 'matrix-js-sdk';
|
import { AutoDiscovery } from "matrix-js-sdk";
|
||||||
import User from '../models/user';
|
import User from "../models/user";
|
||||||
import prettyBytes from "pretty-bytes";
|
import prettyBytes from "pretty-bytes";
|
||||||
import Hammer from "hammerjs";
|
import Hammer from "hammerjs";
|
||||||
import { Thread } from 'matrix-js-sdk/lib/models/thread';
|
import { Thread } from "matrix-js-sdk/lib/models/thread";
|
||||||
import { imageSize } from "image-size";
|
import { imageSize } from "image-size";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import aesjs from "aes-js";
|
import aesjs from "aes-js";
|
||||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||||
import duration from 'dayjs/plugin/duration';
|
import duration from "dayjs/plugin/duration";
|
||||||
|
import i18n from "./lang";
|
||||||
|
|
||||||
export const STATE_EVENT_ROOM_DELETION_NOTICE = "im.keanu.room_deletion_notice";
|
export const STATE_EVENT_ROOM_DELETION_NOTICE = "im.keanu.room_deletion_notice";
|
||||||
export const STATE_EVENT_ROOM_DELETED = "im.keanu.room_deleted";
|
export const STATE_EVENT_ROOM_DELETED = "im.keanu.room_deleted";
|
||||||
|
|
@ -23,43 +24,43 @@ export const ROOM_TYPE_CHANNEL = "im.keanu.room_type_channel";
|
||||||
export const STATE_EVENT_ROOM_TYPE = "im.keanu.room_type";
|
export const STATE_EVENT_ROOM_TYPE = "im.keanu.room_type";
|
||||||
|
|
||||||
// Install extended localized format
|
// Install extended localized format
|
||||||
dayjs.extend(localizedFormat)
|
dayjs.extend(localizedFormat);
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
// Store info about getUserMedia BEFORE we aply polyfill(s)!
|
// Store info about getUserMedia BEFORE we aply polyfill(s)!
|
||||||
var _browserCanRecordAudioF = function () {
|
var _browserCanRecordAudioF = function () {
|
||||||
var legacyGetUserMedia = (navigator.getUserMedia ||
|
var legacyGetUserMedia =
|
||||||
navigator.webkitGetUserMedia ||
|
navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||||
navigator.mozGetUserMedia ||
|
return (
|
||||||
navigator.msGetUserMedia);
|
legacyGetUserMedia !== undefined || (navigator.mediaDevices && navigator.mediaDevices.getUserMedia !== undefined)
|
||||||
return legacyGetUserMedia !== undefined || (navigator.mediaDevices && navigator.mediaDevices.getUserMedia !== undefined);
|
);
|
||||||
}
|
};
|
||||||
var _browserCanRecordAudio = _browserCanRecordAudioF();
|
var _browserCanRecordAudio = _browserCanRecordAudioF();
|
||||||
|
|
||||||
class UploadPromise {
|
class UploadPromise {
|
||||||
aborted = false;
|
aborted = false;
|
||||||
onAbort = undefined;
|
onAbort = undefined;
|
||||||
|
|
||||||
constructor(wrappedPromise) {
|
constructor(wrappedPromise) {
|
||||||
this.wrappedPromise = wrappedPromise;
|
this.wrappedPromise = wrappedPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
abort() {
|
abort() {
|
||||||
this.aborted = true;
|
this.aborted = true;
|
||||||
if (this.onAbort) {
|
if (this.onAbort) {
|
||||||
this.onAbort();
|
this.onAbort();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
then(resolve, reject) {
|
then(resolve, reject) {
|
||||||
this.wrappedPromise = this.wrappedPromise.then(resolve, reject);
|
this.wrappedPromise = this.wrappedPromise.then(resolve, reject);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(handler) {
|
catch(handler) {
|
||||||
this.wrappedPromise = this.wrappedPromise.catch(handler);
|
this.wrappedPromise = this.wrappedPromise.catch(handler);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Util {
|
class Util {
|
||||||
|
|
@ -1169,6 +1170,40 @@ class Util {
|
||||||
hm.get("singletap").requireFailure("doubletap");
|
hm.get("singletap").requireFailure("doubletap");
|
||||||
return hm;
|
return hm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 (i18n.locale == "my") {
|
||||||
|
// Translate to burmese numerals
|
||||||
|
var result = "";
|
||||||
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
var c = str.charCodeAt(i);
|
||||||
|
if (c >= 48 && c <= 57) {
|
||||||
|
result += String.fromCharCode(c + 0x1040 - 48);
|
||||||
|
} else {
|
||||||
|
result += String.fromCharCode(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} else if (i18n.locale == "bo") {
|
||||||
|
// Translate to tibetan numerals
|
||||||
|
result = "";
|
||||||
|
for (i = 0; i < str.length; i++) {
|
||||||
|
c = str.charCodeAt(i);
|
||||||
|
if (c >= 48 && c <= 57) {
|
||||||
|
result += String.fromCharCode(c + 0x0f20 - 48);
|
||||||
|
} else {
|
||||||
|
result += String.fromCharCode(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
export default new Util();
|
export default new Util();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue