Pages

Sunday, 17 April 2011

Advance Localization in ios apps

Localization in ios is usually done using this way. But the main problem with this approach is that to view the application in other language the language has to be changes from the settings of the ios device.
In this post i will present an approach in which you can set the language of the application from within the application.
but before starting lets understand the current localization procedure. we use NSLocalizedString() to get the localized version of any string, which acts as a key to match the key value pair in the localized version of Localizable.strings file.
what infact NSLocalizedString() calls in background is [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] where [NSBundle mainBundle] is the default main bundle.
The trick to use is to get the value of localizedStringForKey from the bundle of your choice. So what we will do is that depending on the language selected we will select the specific bundle and use the [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] to get the localized value of the string.
so lets get started


1- Localize your application using the method describe here. i recommend using this method just so that you can use "genstrings" to create string table.
2- put the localized version of string values in the localized Localizable.strings.
3- Replace the NSLocalizedString with any function name of your choice, i will be using  languageSelectedStringForKey .
4- Write a method definition and implementation of -(NSString*) languageSelectedStringForKey:(NSString*) key where it is accessible in the scope where the localized string is needed.
5- in the languageSelectedStringForKey method select the appropriate bundle depending on the language selected and call [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] on the bundle.
e.g.
for NSString *path= [[NSBundle mainBundle] pathForResource:@"fr" ofType:@"lproj"];  
NSBundle* languageBundle = [NSBundle bundleWithPath:path];
and then get the string like this
NSString* str=[languageBundle localizedStringForKey:key value:@"" table:nil];
str here is the localized string.


again all which i described above have been put in this code and i have placed it on github for any reference.

379 comments:

  1. This is a great post .
    It help me solved my problem..
    Ananthasri.

    ReplyDelete
    Replies
    1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

      IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

      corporate training in chennai corporate training in chennai

      corporate training companies in india corporate training companies in india

      corporate training companies in chennai corporate training companies in chennai

      I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai

      Delete
  2. Wow, thank you so much! Finally a solution that works just like I want it! I've condensed your main function down to the essentials in this pastie:

    http://www.pastie.org/1976594

    ReplyDelete
  3. how to use this method to localize a button text?

    ReplyDelete
  4. You can also set the text of button programatically
    [myButton setTitle: @"myTitle" forState: UIControlStateNormal];

    here set the @"myTitle" using the above method.

    ReplyDelete
  5. It was very useful for me dude!
    Thank you very much!

    ReplyDelete
  6. Why bother when http://www.traductoapp.com/traductopro automates the entire localization for you?

    ReplyDelete
  7. Hello, how are you?
    His method works, however I have a doubt. How do I get the whole application to be "located", I say, we have a variable LocalizedText.h, but if I have another view? How do I call the method - (NSString *) languageSelectedStringForKey: (NSString *) key in the other views?

    I tried putting this in a separate class and could not.

    My mail is: asrsantos@gmail.com

    Thanks

    ReplyDelete
  8. Hi Adriano,

    You can make a singleton. This singleton will implement the "languageSelectedStringForKey" method. Which than you can call from anywhere within your project.
    Read here how to make a singleton class.
    http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/

    ReplyDelete
  9. Very good, that fasten. Thanks very much.

    ReplyDelete
  10. Thank you for the post. Are you aware of how to switch between localized xib files? For an example if you compare Arabic and English languages there is a huge difference of rendering the content. Arabic content should be displayed from right to left. So we need to create the user interface specific to it. How can we switch to the Arabic specific localized XIB user interface upon clicking the language button?

    ReplyDelete
  11. @Amilla In that case above solution may not work for you, Make two nibs and switch between them using
    + (BOOL)loadNibNamed:(NSString *)aNibName owner:(id)owner

    More description at: http://stackoverflow.com/questions/4498822/how-to-change-dynamically-the-xib-of-a-uiviewcontroller

    ReplyDelete
  12. sorry i can't get it .. how to use loadNibnamed to load different nibs using your methods? can you give me a little more details

    ReplyDelete
    Replies
    1. ok i got it myself :D :D

      - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
      {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
      NSString *path= [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"];
      NSBundle* languageBundle = [NSBundle bundleWithPath:path];
      NSArray *nibObjs = [languageBundle loadNibNamed:@"MainViewController" owner:self options:nil];
      UIView *aView = [nibObjs objectAtIndex:0];
      self.view = aView;
      }
      return self;
      }


      i put it here for others when they reach your page :D

      Delete
  13. This comment has been removed by the author.

    ReplyDelete
  14. but i found a problem in this approche that i can't find why it happens .. when i used this approach of calling this in initWithNibName the viewDidLoad is never get called ..why is that..

    ReplyDelete
  15. Thanks for the post..I;m seeing that UIKeyboard is not localized..it comes in english..which should not be the case..could you check this out..thanks

    ReplyDelete
  16. Unfortunately there is no way to control the keyboard language programmatically.

    ReplyDelete
  17. Or you can use an online localization tool such as https://poeditor.com/. It does its job perfectly well.

    ReplyDelete
  18. What will be happen with jailbreak for getting more apps in the iPhone devices?
    read more

    ReplyDelete
  19. The method described in http://www.iphonesdkarticles.com/2008/11/localizing-iphone-apps.html isn`t available anymore... Can you give us a hint?

    ReplyDelete
  20. Nice post, thanks for sharing. Any idea how could I have the same functionality with the Storyboard's strings?

    ReplyDelete
  21. This translation tool could help a lot in the iOS localization process: https://poeditor.com/. It offers possibilities of automatic translation for strings and also of collaborative translator work. It has API and Github integration also.

    ReplyDelete
  22. How to localization more than one languages. ?
    can i localization 5 languages ?

    ReplyDelete
  23. thanks a lot sir...superb article

    ReplyDelete
  24. There is another interesting service that provides sdk and online update for ios apps translation: http://localize.io
    You can manage you localisation files without the need to think about which version of the app you're updating. You also don't need to recompile the app each time you add a new language.

    ReplyDelete

  25. Thanks for sharing information.
    recharge offers
    videocontelecom offers new Customers the proposition will be available on Plan voucher (PV) priced at Rs 76, offering All Local Calls at 25P/min only for 6 months including Rs 63 Talk time; 1050 MB data for 3 month and 100 SMS free/day, with first 2 SMS of the day chargeable at rack rate only in Haryana.

    ReplyDelete
  26. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    Mobile App Development Company in Chennai
    Android app Development Company in Chennai
    ios app development Company in Chennai

    ReplyDelete
  27. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific nice content. And tell people specific ways to live their lives.Sometimes you just have to yell at people and give them a good shake to get your point across.
    Mobile App Development Company
    Android app Development Company
    ios app development Company
    Mobile App Development Companies

    ReplyDelete
  28. Where can I get the latest post on this.

    ReplyDelete
  29. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai

    ReplyDelete
  30. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Android App Development Company

    ReplyDelete
  31. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    <Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text
    Mobile Marketing Services
    mobile marketing companies
    Sms API

    ReplyDelete
  32. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  33. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Mobile Marketing Service
    Mobile Marketing Companies
    Texting API
    Sms API
    sms marketing

    ReplyDelete
  34. IOS is my dream. I hope that I can learn this, but I think it's hope, not more than. Now i work in a company that provide services for IOS development. It also provide outsourcing software services to global market.

    ReplyDelete
  35. Finally I found the solution that work just like I want. Thanks for the post. iPhone Application Developers

    ReplyDelete
  36. Great work.Really appreciate it.

    ReplyDelete
  37. This comment has been removed by the author.

    ReplyDelete
  38. This comment has been removed by the author.

    ReplyDelete
  39. Valuable content. Thanks for sharing this with us.

    ReplyDelete
  40. Those students are eagerly waiting for SSC CGL 2019 Notification. Staff Selection Commission will announce SSC CGL notification in the month of October 2019

    ReplyDelete
  41. National Testing Agency is going to conduct the JEE Main 2020 Examination .the exam is conducted twice in a year in this article we are sharing all the important details for jee main 2020 click here for all the details

    ReplyDelete
  42. Software Development Company We specialize in Blockchain development, Artificial Intelligence, DevOps, Mobile App development, Web App development and all your customised online solutions. Get best impression at online by our services, we are familiar for cost effectiveness, quality, delivery and support.

    ReplyDelete
  43. Nice blog! Full of informative ideas. Thank you, keep sharing.
    web design company in chennai

    ReplyDelete
  44. Aran’s traditional milk is pure A2 milk, Nattu Kozhi Muttai Chennai, Organic Milk Chennai, A2 Milk Chennai, Cow Milk Chennai, Naatu Maatu Paal Chennai Chennai hand-milked in a traditional way from healthy native Indian breeds and reaches your doorstep.

    Milking Process
    The milking is done from indigenous cows by using hands. No machines are used in order to ensure no harm is done to the cows

    Packing Methods
    As soon as milking is done, the milk is filtered and packed in the FSSAI certified place with hairnets and gloves on this packing is done into the 50 microns wrappers which are not reactive to the food items. Again, no machines are used for packing to contribute to the environment, as they consume more water and power.

    Milk Delivery
    As soon as packing and quality check are done, the milk packets are collected and brought for delivery.

    ReplyDelete
  45. very informative post and I found how to localization in iOS apps. In this feature very necessary for for all mobile apps. If anyone looking for mobile app development company in Chennai. You can check it out here: https://dxminds.com/top-mobile-app-development-company-in-chennai/#

    ReplyDelete
  46. BMIT – BSc Medical Imaging Technology – Here is the details about Best BSc Medical Imaging Technology Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best BMIT colleges in Bangalore
    BSc Medical Imaging Technology Colleges In Bangalore

    ReplyDelete
  47. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    top angular js online training

    ReplyDelete
  48. BSc in Optometry – Here is the details about Best BSc Optometry Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best OPT colleges in Bangalore
    Optometry Colleges In Bangalore

    ReplyDelete
  49. Thanks for sharing us.We know how that feels as our clients always find themselves to be the top rankers. It's really easy when you consult that best SEO company in Chennai.

    Best SEO Services in Chennai | digital marketing agencies in chennai |Best seo company in chennai | digital marketing consultants in chennai | Website designers in chennai

    ReplyDelete
  50. nice article.. thanks for posting article!
    Looking for real active followers for instagram profile, then i would recommend to Buy Instagram Followers USA

    ReplyDelete
  51. if you want to pop up your website then you need colocation cage

    ReplyDelete
  52. Nice article... Searching for cheap Mumbai based real instagram followers services, than best to Buy Mumbai Instagram followers without any hassle. More details to Contact us + 917339876756

    ReplyDelete
  53. if you want to pop up your website then you need 2-year ssl certificate

    ReplyDelete
  54. Buy instagram followers India If you want to instagram followers to increase engagement and reach the target audience. More details to contact us.

    ReplyDelete
  55. if you want to pop up your website then you need business email hosting

    ReplyDelete
  56. Wonderful facts and tips, liked your post. Quite helpful and here are best platform to Buy Active Instagram Followers Paytm to increase social media visibility.

    Social Media Marketing Company in India

    ReplyDelete
  57. informative! Worried about QuickBooks Support ? if you are not able to fix QuickBooks Problem, get in touch with QuickBooks expert for instant solution How to Create & Delete Budget in QuickBooks Desktop?

    ReplyDelete
  58. The Post is quality information which helps all reader. Thanks for sharing such an effective blog. It is really helpful for reader and from which reader got solution with this blog. Thank you for sharing valuable information.
    Quick assignment help

    ReplyDelete
  59. very nice blog with great content.Proven ways to rank higher on Google Search result, Seo on page keyword research and content intimation and how to increase your website domain authority.

    best digital marketing agency in chennai
    blog
    fdm chennai
    digital marketing agencies in chennai
    digital marketing consultants in chennai
    Website designers in chennai
    Best SEO Services in Chennai

    ReplyDelete
  60. Top Web Hosting Providers Ranked. We Compare Price, Features and help you choose internet marketing

    ReplyDelete
  61. thanks for sharing great post with us.keep posting.River Group of Salon and spa, T.Nagar, provide a wide range of spa treatments, like body massage, scrub, wrap and beauty parlour services. We ensure unique care and quality service.

    massage in T.Nagar | body massage T.Nagar | massage spa in T.Nagar | body massage center in T.Nagar | massage centre in chennai | body massage in chennai | massage spa in chennai | body massage centre in chennai | full body massage in T.Nagar

    ReplyDelete
  62. Thanks for sharing a useful information about the IOS App localization.

    ReplyDelete
  63. Thanks for sharing nice article. I likes your post. They are read so interesting. Really it was so awesome article.

    Free DoFollow Travel Blog Commenting Sites

    ReplyDelete
  64. Very nice article,thank you for sharing this awesome article with us.

    ios online training

    ReplyDelete
  65. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative
    Rajasthan Budget Tours

    ReplyDelete
  66. Thanks for this blog, I really enjoyed reading your post.
    https://uchaai.com/contact-us/

    ReplyDelete
  67. https://www.seekace.com/about
    best data science course provides by SeekACE Solutions into an emerging leader for product development and customization with a strong blend of Data Science and AI.
    https://www.seekace.com/about

    ReplyDelete
  68. Thank you for sharing such an amazing content
    Also you can visit my site and find similar and informative content on the topic :
    best digital marketing training institute delhi noida


    ReplyDelete
  69. We are the Best Digital Marketing Agency in Chennai.Our team consists of very best of programmers,web developers,SEO experts and many others. we offer all digital marketing service at affordable cost.
    Thanks for the article…
    Best Pay Per Click Service in Chennai
    Best Quality Content Marketing Team in Chennai
    ECommerce website development company in Chennai

    ReplyDelete
  70. Roku device is the best service in the USA, Do you have an issue with your Roku Device? Get instant solution and support by Roku Help Number (+1)833-419-0853. We are dealing with a wide range of Roku streaming players and provide a complete solution for Roku Devices. Call Roku Customer Service Number.

    ReplyDelete
  71. Repair My Phone Today is a leading Cell Phone Repair Store in Oxford providing the best repairing/replacement services for the screen, a battery of smartphones, laptops, tablets, smartwatches, etc. We deal in Apple iPhone, Samsung Galaxy, Huawei phones, Nokia Smartphones & many others

    Phone Screen Repair
    iPhone X Screen Repair
    iPhone XR screen repair
    iPhone 7 screen repair
    iPhone 7 plus screen repair
    iphone 8 screen repair
    iphone 8 plus screen repair

    ReplyDelete
  72. Riverday spa’s speciality signature massage therapies use natural and internationally renowned spa products that offer you a haven of relaxation. We are a Locally owned Business operated by professional massage therapists in a Comfortable and Friendly environment with Convenient Scheduling facilities.
    Thanks for the article…
    Spa in Chennai
    Spa Massage Centre In Tnagar
    Massage Center In Egmore
    Beauty Salon in Porur
    massage center in chennai

    ReplyDelete
  73. Very nice blog post. Thanks for sharing such valuable information. Keep posting in future also.

    Localization

    ReplyDelete
  74. software testing company in India
    software testing company in Hyderabad
    Very informative blog.
    Thanks for sharing such a nice information with us about ios apps.
    keep sharing.

    ReplyDelete
  75. Excellent post! Your post is very useful and I felt quite interesting reading it. Expecting more post like this. Thanks for posting such a good post. https://www.hashstudioz.com/IOT-development-company.html

    ReplyDelete
  76. Nice post!

    Worried About QuickBooks Error ?Get in touch with QuickBooks expert for instant solution.
    Click Here to know how to fix QuickBooks Error 80070057

    Dial on QuickBooks Error Support Number +1-855-977-7463.

    ReplyDelete
  77. Tecocraft is one of the best Mobile App Development Company In UK. We provide a Web Development services, App Development Services and Much More.

    ReplyDelete
  78. iot training in chennai - IoT Training in Chennai - IoT is one of the technologies which has a lot of scope at the very same time very less number of skilled employees in this technology which means this particular technology will give a huge success rate. Join the Best IOT Training Institute in Chennai now.

    Devops training Institute in Chennai - DevOps a combination of Development and operations has an better career .Jobs opportunities are there from startup companies to big mnc. Start to learn DevOps technology soon and secure your job now.

    blue prism training in Chennai - If you choose to learn the blue prism or automation tool you are supposed to have the programming language. start to learn the blue prism training from the Best Blue prism Training Institute in Chennai.

    uipath training in Chennai - UI path technology is one of the fastest developing fields which has a lot of job opportunities such as software developer, Programmer and lot more. Join the Best Uipath Training Institute in Chennai.

    microsoft azure training in chennai -Microsoft azure technology is growing and soon it will be competitive aws. So students who start to learn Microsoft azure now will be well - paid in the future. Start to learn Microsoft azure training in Chennai.

    Chennai IT Training Center

    ReplyDelete
  79. iot training in chennai - IoT Training in Chennai - IoT is one of the technologies which has a lot of scope at the very same time very less number of skilled employees in this technology which means this particular technology will give a huge success rate. Join the Best IOT Training Institute in Chennai now.

    Devops training Institute in Chennai - DevOps a combination of Development and operations has an better career .Jobs opportunities are there from startup companies to big mnc. Start to learn DevOps technology soon and secure your job now.

    blue prism training in Chennai - If you choose to learn the blue prism or automation tool you are supposed to have the programming language. start to learn the blue prism training from the Best Blue prism Training Institute in Chennai.

    uipath training in Chennai - UI path technology is one of the fastest developing fields which has a lot of job opportunities such as software developer, Programmer and lot more. Join the Best Uipath Training Institute in Chennai.

    microsoft azure training in chennai -Microsoft azure technology is growing and soon it will be competitive aws. So students who start to learn Microsoft azure now will be well - paid in the future. Start to learn Microsoft azure training in Chennai.

    Chennai IT Training Center

    ReplyDelete
  80. This is very good post I have read and I must appreciate you to have written this for us.Its really informative.
    Best Digital Marketing Agency in Chennai
    website design in chennai

    ReplyDelete
  81. When it comes to providing best assignment service online,
    Unique Submission makes sure to complete assignment antecedently to offer scholars enough time to proof read the given assignment
    before submitting it to their tutors/professors. We never compromise to timely delivery and deadlines given by our customers.


    Assignment Help Services


    ReplyDelete
  82. When it comes to providing best assignment service online,
    Unique Submission makes sure to complete assignment antecedently to offer scholars enough time to proof read the given assignment
    before submitting it to their tutors/professors. We never compromise to timely delivery and deadlines given by our customers.


    Assignment Help Services


    ReplyDelete
  83. Very Informative Blog, Thanks for sharing such type of contents. We are always looking to update our knowledge. you can visit us at..
    Android training in Jaipur
    Android Institute in Jaipur
    Digital Marketing services and education

    ReplyDelete

  84. These cards are taking over New York
    smart carts
    whats your take??

    ReplyDelete
  85. Nice & Informative Blog !
    QuickBooks Error PS032 is a highly disruptive error that can happen when you are downloading the updates of QuickBooks.Our experts are diverse and talented in fixing all the malicious errors of QuickBooks.

    ReplyDelete
  86. Hello, Comment Reader. Do you find a best tech related blog? We will share a daily Tecocraft Blog in reated Tech, Web Development, and more.

    ReplyDelete
  87. Nice & Informative Blog !
    QuickBooks is an intuitive accounting application for small businesses to handle their finance,you may face some technical complications or queries that can crop up in this wonderful software. To fix such problems, call us on QuickBooks Customer Service.

    ReplyDelete
  88. Your blog is very nice and has sets of the fantastic piece of information. Thanks for sharing with us. If you face any technical issue or error, visit:

    Quickbooks customer service

    ReplyDelete
  89. Hi Dear,
    Thanks for sharing such useful blog. Really! This Blog is very informative for us which contain lot of information about Meditation And Relaxation, I like this post. Please visit at "Universalchemshop", i hope you may like our Marketing service.

    Visit Here - https://www.universalchemshop.com

    Thanks, Regards,

    ReplyDelete
  90. Nice Information. Thanks for sharing. Reach us For the same,
    WEB Technologies,
    LEATHER Products.

    ReplyDelete
  91. Nice Information. Thanks for sharing. Muby Technologies , is a leading pioneer in the field of image editing services.
    We take pride in establishing ourselves as the most reliable partner for your image retouching and photo editing services.
    Reach us

    ReplyDelete
  92. Nice Information. Thanks for sharing. Muby Technologies , is a leading pioneer in the field of image editing services.
    We take pride in establishing ourselves as the most reliable partner for your image retouching and photo editing services.
    Reach us

    ReplyDelete
  93. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support in this area. same as your blog i found another one Mobile Marketing .Actually I was looking for the same information on internet for Mobile Marketing and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete

  94. ADHD often begins in childhood and can persist into adulthood.but at adhdmedshop you can maintain treatment with your child
    adhdmedshop.com

    ReplyDelete


  95. ADHD often begins in childhood and can persist into adulthood.but at adhdmedshop you can maintain treatment with your child
    adhdmedshop.com

    ReplyDelete


  96. ADHD often begins in childhood and can persist into adulthood.but at adhdmedshop you can maintain treatment with your child
    adhdmedshop.com

    ReplyDelete
  97. Its a great post keep sharing this kind of wonderful post !
    Free piping course pdms training in Chennai

    ReplyDelete
  98. Thankyou the sharing great information, We are one of the best call center outsourcing vendors in the United States. At Trupp Global, we are completely dedicated to your business growth. We provide top notch services that can enhance the sales along with customer satisfaction levels.
    Business Process Outsourcing Services

    ReplyDelete