0

This question is regarding the localization from inside the app.

There are several blogs/tutorials that really helps and show the way to do it. The ones which i referred to implement it are as below:

http://learning-ios.blogspot.in/2011/04/advance-localization-in-ios-apps.html

http://www.pastie.org/1976594

I am able to achieve it (with the help of such blogs.. thanks to them).

But i was trying one thing and i had a little doubt regarding the same as below

I am trying to create a same macro as the NSLocalizedString [i.e. NSString *NSLocalizedString(String *key, String *value)]

but with a different macro name something like [NSString *getLocalizedString(String *key, String *value)] in my class and try to just replace NSLocalizedString method with my own macro using the same.

But a serious doubt/concern that i have is, is this technique/way approved by APPLE?

i mean.. can/will this violate the apple terms of non usage of Private API or kind of overriding the same??

Coz i have tried check the same in various blogs.. but was not able to find any specific answer to the same.

Can you please confirm if this can violate the T&C of APPLE or can i go ahead with the custom macro approach?

If possible can u also provide the link/blog/tutorial from which i can understand it better?

Thanks a lot in advance.

Learner
  • 1
  • 3

2 Answers2

1

This won't violate Apple's terms. In fact, they recommend you do this to test your app and make sure you translated all the strings. They demonstrated how to do this in the 2012 WWDC video, session 244 Internationalization Tips and Tricks at the 23:50 mark.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
AlBeebe
  • 8,101
  • 3
  • 51
  • 65
  • WWDC12 session 244 got unpublished by Apple. Likely because there are newer sessions from 2015 and 2016 with the newer Internationalization practices. – Cœur Jun 08 '19 at 12:29
1

I don't see how this is using any kind of private APIs. -[NSBundle localizedStringForKey:] is a public API. You can write whatever macros or functions you want that call it. You can even #undef NSLocalizedString and replace it with your own definition if you want, it's just a C macro.

Tony
  • 3,470
  • 1
  • 18
  • 23
  • Thanks a lot tony for your inputs. :) :) I understand this now better. I was also able to find a few similar solutions (as proposed by you) as below http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language stackoverflow.com/questions/6593561/custom-nslocalizedstring. thanks a lot again :) – Learner Mar 24 '12 at 07:45