In my country(Kazakhstan) phone number +7 (123) 456 7890 is equal to 8 (123) 456 7890.
So one saves numbers with +7, some with 8. I need to compare and verify these two numbers. It is easy, but I wonder if there are countries with rules like this and how to check them?
P.S. It is for an ios app in swift.
Related
I'm working on an app that shows currencies with large numbers.
To make it more user friendly it would be nice to show the numbers with letters, e.g:
$24,514,983,671 -> $24.5B // English
3,306,777.10 € -> 3,31 Mio. € // German
kr 23 000 000 -> kr 23 mill. // Norwegian
The numbers should have minimumSignificantDigits = 1 and maximumSignificantDigits = 3.
How should this be solved in Swift? Is there any library available?
Android has this solution
It seems to be based on swift-corelibs-foundation: Github, but I can't see how to use it in my app.
Will I have to make the logic myself with localized translations?
I have found an answer for using general abbreviations K/M/B for large numbers here: iOS convert large numbers to smaller format, but it does not solve the whole problem.
You will have to implement your own solution, but it is not hard. One way to go would be to create two dictionaries where the key will be the Locale identifier and the value the translation:
let millionTrans = [ "en_US" : "million", ...]
let billionTrans = [ "en_US': "billion", ...]
then get the Locale.current, find out if the amount is in the millions or billions and query the appropriate dictionary to get its value.
An important question came up when I tried to translate an existing iOS application into Lithuanian. I know how the Apple translation system works, especially for languages like English or Hungarian. But how I have to translate Lithuanian nouns in combination with numerals I don’t know.
The Lithuanian grammar in conjunction with numerals works like this for the word "įvykis" (event):
Lithuanian English
0 įvykių 0 events
1 įvykis 1 event
2 - 9 įvykiai 2 - 9 events
10 - 20 įvykių 10 - 20 events
21 įvykis 21 events
22 -29 įvykiai 22 - 29 events
30 įvykių 30 events
the same logic continuous
as of 21
More information about Lithuanian noun declension by numerals can be found in this Wikipedia article.
My question is, what key values have to be filled into the "Localizable.stringsdict" for Lithuanian? For English this file looks like this:
and for Lithuanian the same file looks this:
Those entries in the last table just partly correct. Does anyone know which keys I have to use in order to map my table into the stringsdict table? Which keys/keywords are necessary?
In the stringsdict file you can only have the keys zero, one, two, few, many, and other. That is all you actually need. iOS has its own data (based on information from the Unicode standard) that tells it which of those keys to use based on the actual number.
This is covered in the (now archived) Internationalization and Localization Guide, specifically the Handling Noun Plurals and Units Of Measure chapter with specifics about the stringsdict file in Appendix C.
You may also find language specific rules from Unicode. Scroll down to Lithianian and you will see the built in rules on how the category is used with a given number.
In short, you want the following for your "events" in Lithuanian:
one - %d įvykis
few - %d įvykiai
other - %d įvykių
iOS will know to use one for 1, 21, 31, 41, etc. It will know to use few for 2~9, 22~29, etc. It will know to use other for 0, 10~20, 30, etc.
I'm using the iOS ABPeoplePickerNavigationController to allow a user to select a phone number, but the number I get back is formatted like this:
+44 (0) 20 3162 0001
I can strip out the spaces and the parenthesis, but the number that remains isn't really a valid phone number.
Does iOS offer any way to force ABPeoplePicker to return a valid, canonical phone number i.e.
+442031620001
or will I be fored to apply a regex or something to it?
you will have to apply a regex. but it should just be strip all but optionally + at the beginning
STILL there is no guarantee that'll get you a valid phone number!
e.g. In Addressbook I could write +44 353 1232 (-0 / -1)
to name to alernates
I am trying to use Zebra Printer for printing in French.
The problem which I face is as below.
I want to print in French using Zebra MZ220.
The characters will be dynamic
Zebra's programming manual mentions below
COUNTRY USA
TEXT 4 0 0 8 COUNTRY IS USA
TEXT 4 0 0 15 #$#[]^‘{|}~
will print
COUNTRY IS USA
#$#[]^‘{|}~
When I have to print in French, I have to use the command as below.
COUNTRY FRANCE
TEXT 4 0 0 28 COUNTRY IS FRANCE
TEXT 4 0 0 35 #$#[]^‘{|}~
which will print as
COUNTRY IS FRANCE
//corresponding french characters//
Now, how can I directly send the French characters instead of sending replacement characters?
I have banged my head all around to get an answer with no luck.
Please help.
I'd use some sort of mapping function to perform the translation. You'd call it with what you want to print and it would return what you need to send to get that output, or tell you if that's not possible.
The details depend on the programming language.
I want to extract valid(on the basis of format) mobile numbers from a text.
e.g. I/O some text (987) 456 7890, (987)-456-7890 again some text
O/P 9874567890 9874567890
problem is, there are many valid mobile formats in all over world like.
text = "Denmark 11 11 11 11, 1111 1111 "
// + "Germany 03333 123456, +49 (3333) 123456 "
// + "Netherlands + 31 44 12345678 Russia +7(555)123-123 "
// + "spain 12-123-12-12 switzerland +41 11 222 22 22 "
// + "Uk (01222) 333333 India +91-12345-12345 "
// + "Austrailia (04) 1231 1231 USA (011) 154-123-4567 "
// + "China 1234 5678 France 01-23-45-67-89 "
// + "Poland (12) 345 67 89 Singapore 123 4567 "
// + "Thailand (01) 234-5678, (012) 34-5678 "
// + "United Kingdom 0123 456 7890, 01234 567890 "
// + "United States (987) 456 7890, (987)-456-7890+ etc."
How to cover all mobile formats?
min and max length of the mobile numbers(with or without country code)?
how to recognize that mobile number has country code or not?
You might want to check if this fits your needs: A comprehensive regex for phone number validation
By experience I know how this works in my phone OS. It looks at a long enough sequences of digits, separated by a set of allowed chars.
In principle something like:
[\+]?([0-9]|[\(\).- ]){min,max}
This regex is suboptimal since it also looks for long sequences of separator chars. You will probably need to filter those results out as well.
A very simple method with some false positives, but false positives are IMPO better than misses.
You shouldn't use the list of samples you got as a guide to actual mobile phone numbers.
For example the number sequence shown for the Netherlands is incorrect, in that it doesn't cover just mobile numbers but ALL regular phone numbers (it doesn't cover such things as 0800 and 0900 numbers for which different rules apply) and is missing an element even for that.
I can only assume the list is similarly incorrect for other countries (and of course it's far from complete in that it doesn't cover all countries, but maybe you posted only a fragment).
To parse a phone number you'd have to first remove all white space and other formatting characters from what could be a phone number, then check whether it has the correct length to be one, then try to deduce whether it includes a country code or not.
If it includes a country code but doesn't start with either 00 or + (both are used to indicate an international number) it might not be a phone number after all.
Does it include an area code? If so, is the area code one associated with mobile phones (for example in the Netherlands all mobile phone numbers have area code 06, BUT in the past this wasn't always the case so if you have an old document a 06 area code may not be a mobile number anyway.
After you've deduced that (and AFAIK mobile numbers always include an area code) you have to check if the remaining numbers make up something that could be an actual phone number without area code based on the length of the number (hint: area code + numer together have to be 10 long here, and I think everywhere).
And all that while taking into consideration that the rules may well be different for different countries or even different networks within some countries.
And of course if you find a number that looks like a valid phone number it still may not be.
It could be some other number that just looks like a phone number but isn't.
Simple search of all matching string formats in this case is not right way. The optimal way is using Regular Expressions to find all matches of phone numbers, but Blackberry java don't have built-in capabilities to process Regular Expressions.
But you can use 3-rd party library for J2ME implementing RegEx processing, smth. like this.
// Regex - Check Singapore valid mobile numbers
public static boolean isSingaporeMobileNo(String str) {
Pattern mobNO = Pattern.compile("^(((0|((\\+)?65([- ])?))|((\\((\\+)?65\\)([- ])?)))?[8-9]\\d{7})?$");
Matcher matcher = mobNO.matcher(str);
if (matcher.find()) {
return true;
} else {
return false;
}
}