I want to convert numerals into other language numerals, how can I do this?
I want to be able to support as many languages as possible (google translation supported languages). I’ve been reading and I believe this can be done from charcode.
Here is some code I copied from some Javascript application, but it only supports 2 languages.
TextTools.arabicNumber = function (str) {
var res = String(str).replace(/([0-9])/g, function (s, n, ofs, all) {
return String.fromCharCode(0x0660 + n * 1);
});
return res;
}
TextTools.farsiNumber = function (str) {
var res = String(str).replace(/([0-9])/g, function (s, n, ofs, all) {
return String.fromCharCode(0x06F0 + n * 1);
});
return res;
}
You’ve basically solved the problem already, you just need to look at the Unicode standard to find where the other numeral characters exist. You can check out Code Charts or just use Wikipedia for the character ranges. Some interesting things to note, though:
Not every language/culture uses a decimal positional number system, although most extant ones do. You’ll want to verify that the number symbols are used the same way as they are in the West to be sure you’ve got it correct. For all I know, Japanese or Korean numbers are written out using a different system but they use Western numbers in other contexts the same way the West does. You’ll need to verify all this to ensure you’ve got a correctly working system.
But from a technical translation point-of-view, assuming you’re just going to convert Western numerals to numerals in another script, you’ve got it figured out.
ETA: In reference to a comment, consider the case of traditional Hebrew numbers. Numbers are formed as units + tens + hundreds (actually hundreds + tens + units when reading right-to-left). So 456 becomes 400 + 50 + 6, or in Hebrew, תנו.