Localizating your application is crucial if you want to reach a broader audience, imaging how a Spanish or German kid will react if the game they try to play is in english or french, they just won't buy your game.
The iphone SDK has it's own localization system, which works very well, but as you may know the default localization system does not allow you to change the language in run-time, just use the OS default system, and it also does not allow other languages beyond what's defined on the iphone OS. So, if you want to change the language from a menu in your game there are many things you can do:
- write your own system, which is utterly boring and implies parsing your language files, or...
- overload and use what the framework has to offer.
Note: Although it is used for games it might be used for your own applications as well.
How the new system works
a. The iphone SDK way
The iphone SDK provides the NSLocalizableString("tag", "alternative") macro to obtain the localized string, from the Localizable.strings, for the given "tag" string or in case it didn't find a proper match it returns the "alternative" string.
I'll explain in the Implementation section how to build the Localizable.strings, just know that it has a strings in the format:
"tag" = "Localized text for the tag";E.g.
NSString *localizedStr = NSLocalizableString(@"hello", @"Hello World");b. The new way
//IF it finds the "hello" tag on the localizable.strings for the current OS language it will return the localized string.
//ELSE will return "Hello World"
With adding the LocalizationSystem.h and LcalizationSystem.m you add the following functionality to the default system.
- you'll be fully compatible with what was already done.
- you'll be able to change the language in run-time
- you'll be able to support languages not added in the iphone OS implementation, like Esperanto, Catalá, Elfic,...
It's usage is fairly simple, there has been defined 4 macros that extends the default functionality. These macros are:
1. LocalizationSetLanguage("language")
Using the following macro you'll be able to change the localization default language into the language you want.
// Sets the desired language of the ones you have.The "language" string should match what you have on you Localizable.strings file
// example calls:
// LocalizationSetLanguage(@"Italian");
// LocalizationSetLanguage(@"German");
// LocalizationSetLanguage(@"Spanish");
//
// If this function is not called it will use the default OS language.
// If the language does not exists y returns the default OS language.
- (void) setLanguage:(NSString*) l{
NSLog(@"preferredLang: %@", l);
NSString *path = [[ NSBundle mainBundle ] pathForResource:l ofType:@"lproj" ];
if (path == nil)
//in case the language does not exists
[self resetLocalization];
else
bundle = [[NSBundle bundleWithPath:path] retain];
}
2. AMLocalizedString("tag", "alternative")
Gets the Localized string:
// Gets the current localized string as in NSLocalizedString.The AMLocalizedString works just the same way as the NSLocalizedString.
//
// example calls:
// AMLocalizedString(@"Text to localize",@"Alternative text, in case hte other is not find");
- (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)comment
{
return [bundle localizedStringForKey:key value:comment table:nil];
}
3. LocalizationReset;
Resets all settings, in case you'll allow your user to leave the language settings as default.
// Resets the localization system, so it uses the OS default language.4. LocalizationGetLanguage;
//
// example call:
// LocalizationReset;
- (void) resetLocalization
{
bundle = [NSBundle mainBundle];
}
Gets the current set language.
// Just gets the current setted up language.
// returns "es","fr",...
//
// example call:
// NSString * currentL = LocalizationGetLanguage;
- (NSString*) getLanguage{
NSArray* languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
NSString *preferredLang = [languages objectAtIndex:0];
return preferredLang;
}
Implementation
Step 1. Creating the project
I'll use a Cocos2d 0.99.0 project as I wanted to demonstrate the system on games, but you'll be able to create the project better suits your application.
Step 2. Add localization to your project
To do so, you'll need to:
- in resources group within your project, right click add... -> New File
- I'll appear a window like the following. Go to Mac OS X -> Resources and select Strings File. Name your file "Localizable.string".
Now its time to add the localization you want.
tip: Name it as the language name in english. e.g "spanish", "french", "german",...
Step 3. Add the text.
Now open each of the files to add the text you want to localize, remember the format. Do it in the desired language file.
"tag" = "localized text";
"hello" = "HOLA MUNDO";Add this point is exactly as if you were adding normal localization.
Step 4. Add the new localizatio file to your project.
You have to add the LocalizationSystem.h and LocalizationSystem.m to your project.
This can be done in two ways.
- Right click -> Add existing files... wherever you want to add the files, select them and click ok.
- You can darg from the sample project the group containing both files to your project.
1. Add
#import "LocalizationSystem.h"In the classes that need localization,
2. Use AMLocalizableString instead of NSLocalizableString.
3. Use LocalizationSetLanguage to change the language.
LocalizationSetLanguage(@"Spanish");The label will contain "Hola mundo".
CCLabel* label = [CCLabel labelWithString:AMLocalizedString(@"hello",@"Hello World") fontName:@"Marker Felt" fontSize:32];
Download
You can download a sample project with everything on it.
It consist of a clean project, just to be as familiar as possible, with the library added.
that will run as:
Each button represents a language added and OS, returns to the OS default language.
The files:
LocalizationSystem.h
LocalizationSystem.m
The sample project
Test project
If anyone has any suggestion or question leave it in the comments. I'll be glad to answer.
Thank you for reading.
332 comments:
«Oldest ‹Older 201 – 332 of 332 Newer› Newest»This is really pretty cool place I like it because it has everything I want more on this blog soon.
dentist reseda
This is really pretty cool place I like it because it has everything I want more on this blog soon.
dentist reseda
Regarding all aspects the blog was perfectly nice. gratis datingsite
chatten met vreemden
This info you provided in the blog that was really unique I love it!!!
congratulations guys, quality information you have given!!!
Wilderness Therapy
best credit repair companies
Wasp dudes! Amazing stuff continues the good work.
best electric shaver
If you really desire to get such type of information, visit this blog quickly.
Let's get a graphics service at very affordable rate!
Graphic Designer
best electric razor 2014
Hey to everyone, it’s my first visit of the blog site; this blog includes awesome and actually best info for the visitors.
I am happy to see that you have provided such an incredible and impressive blog for us. best home security companies
dentist reseda
The information you have given in the blog really marvelous and more interesting.
phone lookup service
The information you have given in the blog really marvelous and more interesting.
credit repair companies
Each time I used to always check blog posts within the first hours in the break of day, because I like to get information increasingly more.
Thanks! Great work! Now, I'm traying to play internationalized sound files, using SpriteKit. For example, I would do it like this:
SKAction *readText = [SKAction playSoundFileNamed:HLocalizedString(@"audiofile.mp3", nil) waitForCompletion:YES];
But it always plays the same file. I noticed this method is just for Strings, and there is a localizedImagePathForImg for images, so I did one myself for audio files:
- (NSString *)localizedSoundPathForSnd:(NSString *)soundname type:(NSString *)soundtype
{
NSLog(@"Searching soundPath:%@ -- %@",soundname, soundtype);
NSString * sndPath = [bundle pathForResource:soundname ofType:soundtype];
NSLog(@"Returning soundPath:%@",sndPath);
return sndPath;
}
I call it like this:
SKAction *readText = [SKAction playSoundFileNamed:HLocalizedSoundPath(@"audiofile", @"mp3") waitForCompletion:YES];
When I run it, I get:
*** Terminating app due to uncaught exception 'Missing Resource', reason: 'Resource /Users/myUser/Library/Application Support/iPhone Simulator/7.1/Applications/053433C9-2850-4CE6-821F-6BB1EF4234F9/MyApp.app/es.lproj/audiofile.mp3 cannot be found in the main bundle'
Any ideas? What am I missing?
You guys present there are performing an excellent job.
top seo firm
I’m flattened for your blogs writings and blogs as well. Medical Negligence
auto insurance quote
Pretty remarkable post. I simply came across your blog and desired to say that I have really enjoyed searching your blog posts.
compare auto insurance rates
The written piece is truly fruitful for me personally; continue posting these types of articles.
write my essay
Wonderful, just what a blog it is! This blog has provided the helpful data to us continue the good work.
I absolutely respect and appreciate your point on each and every object. watch brands
This is my very first time that I am visiting here and I’m truly pleasurable to see everything at one place. Loch Duart
I believe this is actually the most useful blog I've been through this entire day. fashion
Hey buddies, such a marvelous blog you have made I’m surprised to read such informative stuff. Loch Duart Salmon
The caliber of information that you're offering is merely wonderful. best seo agency
Your blogs and its stuff magnetize me to return again n again. life insurence
Excellent quality articles are here. This is good site with useful info. trial
Wasp dudes! Awesome stuff keep it up. watch
I need more articles and blogs please post soon. european watch company
I’m glad to find so many useful and informative data on your website. dating tips for women
Great job you people are doing with this website. tips for dating
Bundles of thanks for providing such kind of blogs with the informative and impressive articles. panties for sale
I have looked for so several posts about the blog lovers except this post is of course a nice one, keep on. http://panda-designs.com/rolex-replica/
I am truly appreciative to the owner of this website who has shared this nice article at this wonderful place. Panda Designs
I would never crave to lose out any chance to look throughout your contents. cosmetic dentist south bay
Waooow!! Nice blog, this will be greatly helpful. compare car insurance quotes
Awesome! Immense information there. compare car insurance quotes
Good quality info. Lucky to me I came to your website not on purpose, but now I have bookmarked it. payday advance online
This is very essential blog; it helped me a lot whatever you have provided. seo providers
I knew this blog post was existed someplace. Thanks to post such articles. Will unquestionably be using it very soon. twitter followers
Way cool some valid points! I am grateful for you making this post on hand; the rest of this website is also first-class. Have a great fun. best web 2.0 sites
Hey very nice blog!! Man you have done the Amazing efforts to make this blog... I will surely bookmark your blog. life & style
congratulations guys, quality information you have given!!! Best infographic
congratulations guys, quality information you have given!!! social media infographic
Thanks friends, for providing such enlightening data.dating games
I really enjoy reading and also appreciate your work. payday loans no credit check
You have actually made the good points here. I did lots of search on the same topic and didn’t find such informative blog like yours. building business credit
Loved your blog page!!! The stuff that you have remarked up here is superbly wonderful and I vigorously thank you for the same... home security systems reviews
Amazing, what a post this is! This webpage gives helpful information to us, keep on working hard. Password Manager
Loved your blog page!!! The stuff that you have remarked up here is superbly wonderful and I vigorously thank you for the same... umrah package
There is noticeably much to know on the subject of this. I think you created some excellent points in Features also. umra package
I have understood everything in this article, and I need more on this to complete my study on the topic, thanks to provide such nice details. auto insurance quotes
I get contented to see this selective information. Aspire Atlantis Coils
Loved your blog page!!! The stuff that you have remarked up here is superbly wonderful and I vigorously thank you for the same... web 2.0 service
Nice post! I am really in love with your blog thank you so0o much. High PR blog post service
I truly appreciate your working guys, thumbs up!! home security systems
Really amazing blog!!! I enjoyed the complete article? enormous written. when do i have to pay my auto insurance deductible
You have really selected the suitable topic; this is one of my favorite blogs. auto insurance deductibles and premiums
I'm also visiting this site regularly, this web site is really nice and the users are genuinely sharing good thoughts.payday loans in new york york ny
Really amazing blog!!! I enjoyed the complete article? enormous written. SEO Conference
This is wonderful and quite informative blog I have learnt so many things from here. build corporate credit fast
Loved your blog page!!! The stuff that you have remarked up here is superbly wonderful and I vigorously thank you for the same... how to build business credit fast
Really amazing blog!!! I enjoyed the complete article? enormous written. build business credit
I'm also visiting this site regularly, this web site is really nice and the users are genuinely sharing good thoughts.payday loans
This is wonderful and quite informative blog I have learnt so many things from here. judi bola online
Nice explanation here to make understand the people. Thanks for this
build corporate credit fast
I know this is quality based blogs along with other stuff.cash payday loan
This is wonderful and quite informative blog I have learnt so many things from here. online payday advance loans
This is wonderful and quite informative blog I have learnt so many things from here. online payday advance loans
Backup iOS devices to your computer
This is one amongst my desired blogs; I have got enough knowledge through this. http://www.noriomatsumoto.com/build-corporate-credit-with-ease/
Thanks for the entire information you have given here to impart knowledge amongst us? painter calgary
Yeah nice Work, full of great Info… This is one amongst the most Amazing Site Dude… orogoldcleopatra.com
Hello! If you ever need an intuitive and online software localization platform for your translation projects, I recommend to give https://poeditor.com/ a try, because it has a friendly interface and there are some helpful features like automatic translation, API, productivity mode, realtime translation system, GitHub and Bitbucket integration, designed to simplify the collaborative translation work. It understands many language files such as .po, .pot, .xliff, .string, .resx/resw. Cheers!
Keep the ball rolling you have done the great job here. Health Insurance Jacksonville
This is wonderful and quite informative blog I have learnt so many things from here. Health Insurance Jacksonville
Hello! After browsing some amongst the post I felt this is totally new to me. Anyhow, I’m absolutely happy to find this. healthcare insurance company
I know that this site has quality based content; I always enjoy reading your posts. Health Insurance Tampa
This is wonderful and quite informative blog I have learnt so many things from here. nutrisystem reviews
Wowww! Thanks a lot baby! I always required writing in my site something very special like your blog has. You have really helped me a lot.
car ins
Totally Awesome to customization of iPhone game.. thanks for adding it..
Best Antivirus for MAC
Excellent post guys! Your blog is attention-grabbing! Keep continuing the good work!
Lakeville bathroom remodel
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.
I love this blog because it is user friendly with appreciative information.faxless payday loan
After all, what an awesome site and enlightening posts, I would surely bookmark this! learn more here
Hello! After browsing some amongst the post I felt this is totally new to me. Anyhow, I’m absolutely happy to find this. visit here
How do you extract pics from iPhone backup?
I was searching about this issue as you have discussed very clearly and lovely manner that I don’t have to go now any other webpage. pool builders wylie
Hi there! You can localize your app for international markets by using a collaborative translation management platform like https://poeditor.com/. Its great and easy to use work interface, even by non-technical people, makes the localization process easier for all users.
Unit Link Commonwealth Life - Commonwealth Life
If somebody wants expert take on the main topic of blogging next I advise him/her to go to this site, continue the fussy job. payday loans no credit check
Thanks for sharing it .really informative content.
Mobile Application Development
Thanks to share this blog with us .Really great job to discuss ideas about web Development
nice blog.Thankew to share this post with us. Mobile app development also provide great info. about this application.
Thanks to post your blog. useful content.<a href='http://www.elitesmartcare.com/"> Web Application development </a>
Nice post.Thanks to share your ideas with us. Web Application Development
Thanks to share this useful information with us. Nice blog. Web Development
I'm also visiting this site regularly, this web site is really nice and the users are genuinely sharing good thoughts. Vine Vine Skin Care
I'm also visiting this site regularly, this web site is really nice and the users are genuinely sharing good thoughts. Vine Vine Skin Care
HOW I GOT MY LOAN FROM DR PURVA PIUS LOAN FINANCE (urgentloan22@gmail.com)
Hello Everybody,
My name is Mrs Sharon Sim. I live in Singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of S$250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of S$250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius,via email:(urgentloan22@gmail.com) Thank you.
LOAN APPLICATION FORM:
=================
Full Name:................
Loan Amount Needed:.
Purpose of loan:.......
Loan Duration:..
Gender:.............
Marital status:....
Location:..........
Home Address:..
City:............
Country:......
Phone:..........
Mobile / Cell:....
Occupation:......
Monthly Income:....
Contact Us At :urgentloan22@gmail.com
webnet provides custom application development services. offering the highest quality Application development, software development services Islamabad..
As flexible use is getting more broad, in this way it is key and gainful to give negligible helpful versatile portable Mobile App Development Services as they are essential for the customers and business also.
Your website is terribly informative and your articles are wonderful. comprar bellavei
That’s a nice site you people are carrying out there. bellavei
I read your blogs regularly. Your humoristic way is amusing, continue the good work! progressive leasing
I feel happiness to read the content that you are posting. OROGOLD Cosmetics reviews
Your articles make whole sense of every topic. OROGOLD
Whatever you have provided for us in these posts really appreciative. car insurance
Hmm!! This blog is really cool, I’m so lucky that I have reached here and got this awesome information. payday loans online
It’s my fortune to go to at this blog and realize out my required stuff that is also in the quality. lifeinsurance
I got this blog site through my friends and when I searched this really there were informative articles at the place. payday advance
Quickly this site will indisputably be famous among all blogging people, because of its fastidious articles or reviews. auto insurance quotes
Hi, I do think this is an excellent web site. I stumbledupon it ;) I'm going to come back once again since I book marked it.
http://www.redsqware.com/
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
wholesale Granite Stone supplier
I am actually delighted to read this post that carries countless of helpful information, thanks!
German website localization
Glad to read it has helped you!
Medical localization
Awesome work! test project and project files are not available. Can someone please re upload!
Globalization has decidedly made promoting straightforward for various associations wherever all through the world. Translation or limitation is an astoundingly fundamental part of an association's globalization for it can speak to the snapshot of truth the associations. Here are possibilities for the Game localization companies, Game confinement Services, Video amusements limitation, Gaming Translation Agency, Gaming Translation Company and Gaming Translation Services.
Just wish to say your article is as astounding. The clearness for your publish is just great and that i can think you’re an expert in this subject. Well with your permission let me to take hold of your RSS feed to stay up to date with imminent post. Thank you a million and please carry on the rewarding work. https://adamfantacy.tumblr.com/
Rally support for a trigger, cherished one, group or mission by selling custom t-shirts and amassing donations on-line. https://adamfantacy.tumblr.com/
Globalization has emphatically made propelling clear for various affiliations wherever all through the world. Elucidation or confinement is an astoundingly essential part of an association's globalization for it can address the see of truth the affiliations. Here are potential results for the Game confinement affiliations, Game restraint Services, Video beguilements limitation, Game localization Services, Gaming Translation Company and Gaming Translation Services.
Existem três tipos de extensões de cílios: os sintéticos, os de seda e também os de vison (mink, mamífero cuja pele é muito usada para casacos de pele). trueinvestde.wikidot.com
January’s numbers have actually been owned greatly by the multi-state measles outbreak that came from two Disney amusement park in California in December, Schuchat claimed. trueinvestde.wikidot.com
Por ende, la interpelación del dinero cobrado inadecuadamente como consecuencia de el requisito suelo puede reclamarse aunque cuando el parroquiano haya refrendado un contrato renunciando a sus legítimos derechos. My Blog http://xerobuff.weebly.com/
Heya superb website! Does running a blog such as this take a great deal of work? I’ve very little knowledge of programming however I was hoping to start my own blog in the near future. Anyways, should you have any suggestions or tips for new blog owners please share. I understand this is off subject nevertheless I just had to ask. Thank you! My Blog http://xerobuff.weebly.com/
After being informed, I do not relent giving back credit to the author for great efforts. It is usually very good to let the author know that he or she is doing a perfect job because it is through such information that the author is motivated. Even without reading much of the details in this article, it is easy to notice that it is valuable. Research paper structuring help
Amazing information you are sharing. Thanks for it. I spent too much time to find different blogs but this is really a unique blog for me. Mobile Application Development Company
I did not know about this feature before. Now i will use this in my iphone and will surely enjoy my game.
Cheap Umrah Packages
Thank you for the nice article here. Really nice and keep update to explore more gaming tips and ideas.
Game QA Company
Game Functionality Testing
Game Compatibility Testing
Thanks for sharing this content with us.
Looking forward to reading more. Great blog for schools. Really looking forward to read more. Really Great.
Kendriya Vidyalaya No 1 NHPC Chamera
Kendriya Vidyalaya No 2 NHPC Chamera
Kendriya Vidyalaya Hamirpur
Kendriya Vidyalaya Nadaun
Kendriya Vidyalaya YOL Cantt
Kendriya Vidyalaya Palampur
Kendriya Vidyalaya Alhilal
Kendriya Vidyalaya Naleti
Kendriya Vidyalaya Dharamshala
Kendriya Vidyalaya Bhanala
mmorpg oyunlar
İnstagram Takipci Satin Al
Tiktok Jeton Hilesi
tiktok jeton hilesi
antalya saç ekimi
referans kimliği nedir
instagram takipçi satın al
metin2 pvp serverlar
instagram takipci
smm panel
smm panel
iş ilanları
instagram takipçi satın al
hirdavatciburada.com
beyazesyateknikservisi.com.tr
SERVİS
TİKTOK PARA HİLESİ
Post a Comment