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 6662925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:26:35+00:00 2026-05-26T02:26:35+00:00

I would like to implement a multi language support for my app. So I

  • 0

I would like to implement a multi language support for my app. So I created the Localizing.strings file and all that stuff and translated my interface. So far so good …

Now I want to duplicate my database in order to have a *.db-file for every single language. So I did and then I clicked via XCode on the “+” under the Localization tab. I now have a *.db-file in my en.lproj and de.lproj folder.

My problem: If I want to copy the db-files to the app’s documents directory the *.db file is not available of course because it is in the *.lproj-folder. Is there any command to get the right lproj-folder?

To clarify my needs:
This doesn’t work

[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"mydatabase.db"]

… this does:

[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"de.lproj/mydatabase.db"]

… but I don’t want to add the “de.lproj” and “en.lproj” etc. manually. Is there any way to fix it dynamically?

  • 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-05-26T02:26:36+00:00Added an answer on May 26, 2026 at 2:26 am

    What you want is the current language locale, the following code should return the code:

    NSArray *languagesArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
    NSString *currentLanguage = [languagesArray objectAtIndex:0];
    

    You can then do the following

    [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.lproj/mydatabase.db", currentLanguage]];
    

    You may want to check if the path exists and is a valid file, if not maybe use some default path like the one for English (en.lproj)

    Edit: There is another way you can do this using NSLocale’s preferred languages because then you get a list of the preferred languages, so some updated code for the first bit would be:

    NSArray *languagesArray = [NSLocale preferredLanguages];
    NSString *currentLanguage = [languagesArray objectAtIndex:0];
    

    In the end, you’d end up with something like so:

    NSString *pathComponent = [NSString stringWithFormat:@"%@.lproj/mydatabase.db", currentLanguage];
    NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:pathComponent];
    NSString *activePath = nil; // This will store the active language file
    
    // Check if the file exists...
    if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
        activePath = path;
    } else {
        activePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"en.lproj/mydatabase.db"]; // Fallback
    }
    

    Please note, the above code is untested but should suffice. You may need to modify it a little…

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

Sidebar

Related Questions

I would like to implement multi-touch in my applications for Windows Mobile. The applications
I would like to implement a function with R that removes repeated characters in
We would like to implement a web form that automatically saves content at regular
I would like to implement per-directory quotas for a multi-user web application we're developing.
I have a PHP application and now I need to implement multi language support.
I'm building a multi-OS mirroring system which I would like to implement using a
Google Chrome and IE8 implement multi-process support for each tab. How would I implement
I would like to implement a distinct thread for each route in apache camel.I
I would like to implement a very simple way to store a variable containing
I would like to implement a simple queueing service specific to a project. Where

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.