I am still paying dearly for learning iOS development, so please be kind.
I have an iOS application containing around 400 NSString
litterals. I never thought that I would want to localize this app later on, so while being aware of NSLocalizedString
I decided to not use them for my project.
Now the world has changed and I need to localize this application. Is there any tool/script I can use that will run through my .m
files and "search/replace" my NSStrings
with NSLocalizedStrings
before I extract them with genstrings?
Thanks Roger
You made a mistake not writing your code correctly the first time, and now you have to pay the price.
You need to go through your program manually and change user-visible string literals to calls to NSLocalizedString.
Note that you do NOT want to globally change all string literals. Things like dictionary keys should not be localized.
Always, ALWAYS, use NSLocalizedString to create localized strings. It's only a few more characters to type, and it makes internationalizing your code DRAMATICALLY easier.
The good news is that the pain of doing this will serve as a bitter lesson and you likely won't make the same mistake again.
Yes! A find and replace regex will speed up this up.
In the find bar put:
(".*")
In the replace bar:
NSLocalizedString($1,comment:"")
This will change "normalString" to NSLocalizedString("normalString",comment:"")
So go through your code and on the ones you want to replace just press replace, this is a massive timesaver!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With