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

  • SEARCH
  • Home
  • 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 9120351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:36:29+00:00 2026-06-17T05:36:29+00:00

I want to create an iPhone application with English and Arabic language. I checked

  • 0

I want to create an iPhone application with English and Arabic language. I checked the Internationalization document for language switcher, however to take that into effect I have to manually go and change the iPhone setting. I don’t want to do that. So what I am planning is on home screen I will have two button as English and Arabic. If user click Arabic, I will have arabic text and if user select English, app will be in english.

Any idea/ suggestion how to get this done?

Note: I don’t want to manually go and change the language.


Edit 1

As per @Jano, I have done below.

Created new project. Added Arabic in Localization. Now I have two storyboard and two InfoPlist.strings file.

Added Localization.h and .m file as shown in answer.

Directory structure is MyProject-ar.lproj & MyProject-en.lproj

Content of Plist are "myButton01" = "Back"; & "myButton01" = "ظهر";

First View Controller have two button as English and Arabic. Called action on those button.

- (IBAction)pressedEnglish:(id)sender {
    [Localization sharedInstance].fallbackLanguage = @"ar";
    [Localization sharedInstance].preferredLanguage = @"en";
    NSLog(@"pressed english");
}

- (IBAction)pressedArabic:(id)sender {
    [Localization sharedInstance].fallbackLanguage = @"en";
    [Localization sharedInstance].preferredLanguage = @"ar";
    NSLog(@"pressed arabic");
}

In second view controller, I added one button and gave name as myButton. Now in viewDidLoad, I have

[self.myButton setTitle:localize(@"myButton01") forState:UIControlStateNormal];

I hope this should be working, however when I run the project, I see button as myButton01

Any reason why this is happening?


Edit 2

I got Edit 1 problem. I renamed InfoPlist.strings to Localizable.strings and it worked. But but but, I am still getting Arabic text irrespective of whatever button I press.

When finding reason, I found that it was because of below statement that we have in Localization.m

static Localization *shared = nil;
dispatch_once(&pred, ^{
    shared = [[Localization alloc] init];
    shared.fallbackLanguage = @"en";
    shared.preferredLanguage = @"ar";

The problem is at last two lines. As we have set Arabic as preferredLanguage, I am always seeing the arabic text.

What changes will I need to do so that I can have it as changeable as per button pressed.

  • 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-17T05:36:31+00:00Added an answer on June 17, 2026 at 5:36 am

    You want to set the language of the app from the app UI ignoring the user preference on the device. This is unusual, but here you go…

    First write all your language strings on a directory structure like this:

    i18n/en.lproj/Localizable.strings
    i18n/ar.lproj/Localizable.strings
    

    Create an additional directory with the corresponding two letter code for each additional language supported.

    If the files are recognized as i18n resources, they will be presented like this:
    enter image description here

    Files will have a key=value with the following format:

    "button.back" = "ظهر";
    

    In your code, replace any localizable string with the key. Example:

    [self.stateBtn setTitle:localize(@"button.back") forState:UIControlStateNormal];
    

    Usually you would use NSLocalizedString(@"key",@"fallback") but since you want to ignore iPhone settings, I wrote a localize(@"key") macro above that will have the following implementation:

    Localization.h

    #ifndef localize
    #define localize(key) [[Localization sharedInstance] localizedStringForKey:key]
    #endif
    
    @interface Localization : NSObject
    
    @property (nonatomic, retain) NSBundle* fallbackBundle;
    @property (nonatomic, retain) NSBundle* preferredBundle;
    
    @property (nonatomic, copy) NSString* fallbackLanguage;
    @property (nonatomic, copy) NSString* preferredLanguage;
    
    -(NSString*) localizedStringForKey:(NSString*)key;
    
    -(NSString*) pathForFilename:(NSString*)filename type:(NSString*)type;
    
    +(Localization*)sharedInstance;
    
    @end
    

    Localization.m

    #import "Localization.h"
    
    @implementation Localization
    
    +(Localization *)sharedInstance
    {
        static dispatch_once_t pred;
        static Localization *shared = nil;
        dispatch_once(&pred, ^{
            shared = [[Localization alloc] init];
            [shared setPreferred:@"en" fallback:@"ar"];
        });
        return shared;
    }
    
    -(void) setPreferred:(NSString*)preferred fallback:(NSString*)fallback 
    {
        self.fallbackLanguage = fallback;
        self.preferredLanguage = preferred;
        NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings" inDirectory:nil forLocalization:self.fallbackLanguage];
        self.fallbackBundle = [[NSBundle alloc] initWithPath:[bundlePath stringByDeletingLastPathComponent]];
        bundlePath = [[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings" inDirectory:nil forLocalization:self.preferredLanguage];
        self.preferredBundle = [[NSBundle alloc] initWithPath:[bundlePath stringByDeletingLastPathComponent]];
    }
    
    -(NSString*) pathForFilename:(NSString*)filename type:(NSString*)type
    {
        NSString *path = [self.preferredBundle pathForResource:filename ofType:type inDirectory:nil forLocalization:self.preferredLanguage];
        if (!path) path = [self.fallbackBundle pathForResource:filename ofType:type inDirectory:nil forLocalization:self.fallbackLanguage];
        if (!path) NSLog(@"Missing file: %@.%@", filename, type);
        return path;
    }
    
    -(NSString*) localizedStringForKey:(NSString*)key
    {
        NSString* result = nil;
        if (_preferredBundle!=nil) {
            result = [_preferredBundle localizedStringForKey:key value:nil table:nil];
        }
        if (result == nil) {
            result = [_fallbackBundle localizedStringForKey:key value:nil table:nil];
        }
        if (result == nil) {
            result = key;
        }
        return result;
    }
    
    @end
    

    This will use lookup the key strings in the arabic file, and if the key is missing, it will look in the arabic file. If you want it the other way, do the following from your button handlers:

    [[Localization sharedInstance] setPreferred:@"ar" fallback:@"en"];
    

    Sample project at Github.

    If localisation doesn’t work

    If localisation doesn’t work, use the plutil command line tool to verify the format of the file. It should output: Localizable.strings: OK. Example:

    $ plutil -lint Localizable.strings
    Localizable.strings: OK
    

    This format is described in Internationalization Programming Topics > Localizing String Resources. You can optionally add // single-line or /* multi-line */ comments. For non latin languages it’s recommended to encode Localized.strings in UTF-16. You can convert between encodings in the inspector pane of XCode.

    If it still doesn’t work, check that you are copying the Localizable.strings file in the Copy files phase of your target. Note that when you add Localizable.strings files there, sometimes they appear in red, keep doing it until a file appears in black, then delete the red ones (hacky I know, blame Xcode).

    copy files

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

Sidebar

Related Questions

I want to create an iPhone application that can call web services on a
I want to create an iPhone application which will display notification that an incoming
Possible Duplicate: internationalization of an iPhone Application I know that its possible to create
I have seen the Contacts in iPhone Simulator. I want to create an application
I want to create an extremely simple iPhone program that will open a telnet
I want to ask a question about the UINavigationController on iPhone application. I create
I want to create two targets for my application iphone and ipad version. My
I am new to iPhone development. I want to create an iPhone application, using
I would like to create a toggle button in my iPhone application. However, I
I am newbie for iPhone application and I want to create iPhone application based

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.