Basic support for translated numerals

This commit is contained in:
N-Pex 2025-01-10 11:44:26 +01:00
parent b1acf7d1f7
commit 5294069b20
2 changed files with 37 additions and 4 deletions

View file

@ -15,8 +15,7 @@ function importAll(r) {
}
importAll(require.context('@/assets/translations/', true, /\.json$/));
export default new VueI18n({
const vue18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
silentFallbackWarn: true,
@ -51,4 +50,37 @@ export default new VueI18n({
return (choicesLength < 4) ? 2 : 3;
}
}
})
})
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;