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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:50:04+00:00 2026-05-16T20:50:04+00:00

Example: en_GB is output, need en. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSArray *languages =

  • 0

Example: en_GB is output, need en.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
NSLog(@"%@", currentLanguage);
  • 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-16T20:50:05+00:00Added an answer on May 16, 2026 at 8:50 pm
    NSArray *arrayOfSeperatedString = [currentLanguage componentsSeparatedByString:@"_"];
    NSLog(@"%@", [arrayOfSeperatedString objectAtIndex:0]);
    

    edit:

    A better way would be:

    NSLocale *currentLocale = [[[NSLocale alloc] initWithLocaleIdentifier:currentLanguage] autorelease]; //Sets the what laguage the language name and country name should be written in
    NSString *displayNameString = [currentLocale displayNameForKey:NSLocaleIdentifier value:currentLocale]; //Sets what language you want written..
    
    NSLog(@"The current language is: %@", displayNameString);
    

    Now if the current language is french (fr_FR) this returns:

    The current language is: français (France)
    

    If the current language is english (en_US) this returns

    The current language is: English (United States)
    

    Now if you want to ommit the country name use componentsSeperatedByString:@" (" as described above..

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

Sidebar

Related Questions

I would like to change: http://example.com/index.php?p=blog&pid=2&lid=1&l=en into just http:// example.com/en/blog.html or just http:// example.com/blog.html
I am writing some documentation and I have a little vocabulary problem: http://www.example.com/en/public/img/logo.gif is
I'm using the example found here: http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_01 The issue is that when I specify
I looked at this example http://msdn.microsoft.com/en-us/library/bb399420.aspx and clicked on DataContext.CreateDatabase which brought me to
I used this MSDN example to construct my console host app: http://msdn.microsoft.com/en-us/library/ms731758.aspx It works
Example: #include <iostream> using namespace std; int main() { wchar_t en[] = LHello; wchar_t
How can I create pdf documents with 2D barcodes (for example QR code http://en.wikipedia.org/wiki/QR_Code
I'm looking at the TPL exception handling example from MSDN @ http://msdn.microsoft.com/en-us/library/dd537614(v=VS.100).aspx The basic
Here's a contrived example of my code: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
So, this example comes right from MSDN. http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readelementcontentasbase64.aspx Pretty much the only thing I

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.