Opinions seem to differ on what numeral system to use when localising software to Hindi:
Java
hi: Western Arabic
Locale hi = new Locale("hi")
System.out.format(hi, "%d", 123456)
-> 123456
hi_IN: Devanagari
Locale hi_IN = new Locale("hi", "IN")
System.out.format(hi_IN, "%d", 123456)
-> १२३४५६
JavaScript - nodejs
hi: Western Arabic
console.log(new Intl.NumberFormat('hi').format(123456.7890));
-> 1,23,456.789
hi-in: Western Arabic
console.log(new Intl.NumberFormat('hi-IN').format(123456.7890));
-> 1,23,456.789
JavaScript - Firefox
hi: Western Arabic
console.log(new Intl.NumberFormat('hi').format(123456.7890));
-> 1,23,456.789
hi-in: Western Arabic
console.log(new Intl.NumberFormat('hi-IN').format(123456.7890));
-> 1,23,456.789
moment.js
hi: Devanagari
https://github.com/moment/moment/blob/develop/locale/hi.js#L13-L36
So...
Which is correct? Or is there no definitive answer?
Related
I want to validate the password to include at least 1 Arabic or English letter and at least 1 Arabic or English number and at leats 8 length password, my old code that was made for English only was like :
let passwordRegex = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"
if (!NSPredicate(format:"SELF MATCHES %#",passwordRegex).evaluate(with: password)){
return false
}
and then i found this answer for Arabic characters and digits, then i tried to merge both like this :
let passwordRegex = "^(?=.*[A-Za-zء-ي])(?=.*٠-٩\\d)[A-Za-zء-ي٠-٩\\d]{8,}$"
if (!NSPredicate(format:"SELF MATCHES %#",passwordRegex).evaluate(with: password)){
return false
}
please advise what's wrong, thanks in advance
Since an English or Arabic letter regex (as described in this answer you linked to, also, see this answer, too) is [a-zA-Za-z\u0621-\u064A] and an English or Arabic digit regex is [0-9\u0660-\u0669] you may use
let passwordRegex = "^(?=.*[a-zA-Z\\u0621-\\u064A])(?=.*[0-9\\u0660-\\u0669])[a-zA-Za-z\\u0621-\\u064A0-9\\u0660-\\u0669]{8,}$"
NOTE: you do not need the outer ^ and $ anchors because MATCHES requires the pattern to match the whole string input.
Another way to match an Arabic letter with ICU regex used in Swift is to use [\p{L}&&[\p{script=Arabic}]] (it is an intersection inside a character class, it matches any letter but from the Arabic character set). Same with a digit: [\p{N}&&[\p{script=Arabic}]]. Then, the regex will look like
let passwordRegex = "^(?=.*[\\p{L}&&[\\p{script=Arabic}A-Za-z]])(?=.*[\\p{N}&&[\\p{script=Arabic}0-9]])[\\p{L}\\p{N}&&[\\p{script=Arabic}a-zA-Z0-9]]{8,}$"
So, here
[\\p{L}&&[\\p{script=Arabic}A-Za-z]] - any letter but it should belong to either ASCII letters or Arabic script
[\\p{N}&&[\\p{script=Arabic}0-9]] - any digit but either from 0-9 range or Arabic script
[\\p{L}\\p{N}&&[\\p{script=Arabic}a-zA-Z0-9]] - any letter or digit but only from the ASCII 0-9, A-Z, a-z and Arabic script.
Note also, that in order to match any letters, you may use\p{L} and to match any digits you may use \d (they are Unicode aware in ICU library). So, *in case t does not matter if the letters or digits are Arabic, English, Greek or whatever, you may use
let passwordRegex = "^(?=.*\\p{L})(?=.*\\d)[\\p{L}\\d]{8,}$"
The issue is simple, when I try to do auto translate from English to a detected language I got an error, the formula is:
=GOOGLETRANSLATE("Cat"; "en"; "auto")
and the error is something like
Error, Google Translate does not support translation from en to pl-PL.
The problem (I think) is that GOOGLETRANSLATE is supposed to get language as two letter code when default value is language + country code (which is not supported https://support.google.com/docs/answer/3093331?hl=en)
Is it possible to fix that? I would like to translate to user's language (so I want to use "auto" value), no matter what is the language and I assume that if the problem occurs for one language it will happen for different one.
Have you tried to use ; instead of ,.
Example:
=GOOGLETRANSLATE(A1 ; "auto"; "bg")
I have the same issue for Russian. The formula =GOOGLETRANSLATE("Cat"; "en"; "auto") gives the error:
Google Translate does not support translating from en to ru-RU.
This is Google issue, the best way is to report it:
Menu: Help > Report a problem
Here's a workaround:
make a script to detect sheet's locale.
use regex to extract first part of a locale string.
Here's the sample code:
function getLocale()
{
var locale = SpreadsheetApp.getActive().getSpreadsheetLocale(); // pl_PL
return /(.*)_/.exec(locale)[1]; // pl
}
The usage:
=GOOGLETRANSLATE("Cat"; "en"; getLocale())
auto-translate is supported only for these 16 locales:
brazil
germany
mexico
spain
canada (english)
hong kong
philippines
taiwan
china
italy
portugal
united kingdom
france
japan
south korea
united states
see more at: https://stackoverflow.com/a/73767720/5632629
I have created a website and I would like to provide locale support with arabic culture. When I see the locale strings there are many culture codes for arabic. Which one is best to use in my website for arabic language?
ar-DZ Arabic - Algeria
ar-BH Arabic - Bahrain
ar-EG Arabic - Egypt
ar-IQ Arabic - Iraq
ar-JO Arabic - Jordan
ar-KW Arabic - Kuwait
ar-LB Arabic - Lebanon
ar-LY Arabic - Libya
ar-MA Arabic - Morocco
ar-OM Arabic - Oman
ar-QA Arabic - Qatar
ar-SA Arabic - Saudi
ar-SY Arabic - Syria
ar-TN Arabic - Tunisia
ar-AE Arabic - United Arab Emirates
ar-YE Arabic - Yemen
The best thing is not to specify a particular country and use just ar (if allowed by your localization framework).
As we know french numbers use "," as decimal separators as compared to english.
eg: English : 10.25% is
French : 10,25%
I am able to successfully translate english numbers to french:
number_with_precision(121.45, locale: :fr)
#=> 121,45
But I am not able to translate french numbers to english:
number = number_with_precision(121.45, locale: :fr)
number #=> 121,45
number = number_with_precision(number, locale: :en)
number #=> 121,45
The number remains in french locale.
This is my en.yml:
en:
number:
format:
delimiter: ! ','
separator: '.'
significant: false
strip_insignificant_zeros: false
this is my fr.yml:
fr:
number:
format:
delimiter: ! ','
separator: ','
significant: false
strip_insignificant_zeros: false
Is there a mistake in my translation file which is causing this?
What you are doing with what you consider as "English to French" is not "from English". 121.45 is a Ruby numeric literal, and is neither English nor French (although the literal itself uses a period for decimals like in the English notation although it uses underscore for delimiter, unlike English, which uses the comma).
In what you called "French to English", you are passing a string in French format. That is why it does not work. How is number_with_precision supposed to know that the string passed is written in French notation?
How do I change a currency in a Latex template? Something that's text based, like South African Rand (symbol > 'R'). Latex doesn't recognize ZAR etc.
FYI: I'm currently using an invoice template.
Within invoices, or any template containing a currency you'll want to change, simply write the next:
\documentclass[letterpaper]{dapper-invoice}
\renewcommand{\$}{\text{R}}
In the above instance, I'm changing $ to ZAR (South African Rand). It's a simple way of changing the currency to a text-like currency (eg. 'R').