Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:29:07+00:00 2026-06-15T18:29:07+00:00

Simply, I have a positive integer [9, 393, 3, 993], and I would like

  • 0

Simply, I have a positive integer [9, 393, 3, 993], and I would like to localize it to a certain language [٩, ٣٩٣ ,٣ ,٩٣٩].

If I use NSNumberFormatter, it will localize the number according to the user’s locale. However, I want to override that and choose any locale to translate the number to.

I tried the following, did not work:

// user locale is @"en"
NSNumberFormatter* formatter = [NSNumberFormatter new];
[formatter setNumberStyle:NSNumberFormatterNoStyle];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"ar"]];


[formatter setMinimumIntegerDigits:padding];
return [formatter stringFromNumber:@(num)];

The returned string is in English.


Please note that I have a very similar code snippet for NSDateFormatter, but it works as expected. The NSDateFormatter object respects the set locale.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:29:08+00:00Added an answer on June 15, 2026 at 6:29 pm

    It seems I came across a very special case where the locale of the app would just freak out.

    I am changing the default locale of the app by using something like this:

    [[NSUserDefaults standardUserDefaults] setObject:@[@"ar"] forKey:@"AppleLanguages"];
    

    Then, I was trying to get the preferred language and create a locale object from it using:

    NSString* langPrefix = [NSLocale preferredLanguages][0];
    

    Finally, create a new NSLocale object from the returned object. When testing the code, I would change the language from within the app, then close the app through Xcode. I am assuming that the NSUserDefaults would not synchronize, but even if I called the synchronize method, it would still screw up.

    Bottom line is, testing localization should be done by deploying the app, and after the device has been disconnected from Xcode, so the app would run through all the life-cycle stages properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simply subclass of UIButton that will fire off a custom
I have a very simply query like this: SELECT users.id, COUNT(others.id) as c FROM
convert a positive integer number in C++ (0 to 2,147,483,647) to a 32 bit
Pretty positive you have to use .clear, or maybe not as it doesn't seem
I would like to perform a MySQL regular expression which will check a string
I have a sequence of integers (positive and negative) like this one: 12,-54,32,1,-2,-4,-8,12,56,-22,-21,4,17,35 And
I have a simple enum: public enum MyEnum { [Description(Zero)] Zero, [Description(A positive number)]
I simply have 2 tabs and used Experience - Multiple Android Activities in a
I simply have 2 tabs and used Experience - Multiple Android Activities in a
First of all, excuse my poor topic title. I simply have no idea how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.