I have a Localizable.strings
file for my project's i18n, and a lib uses KYLocalizable.strings
.
I have considered to make Localizable.strings
"subclass" from KYLocalizable.strings
, but it cannot as far as I know. So instead, I want to define a function macro like what SDK does:
#define NSLocalizedString(key, comment) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
#define NSLocalizedStringFromTable(key, tbl, comment) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:(tbl)]
Pseudo code:
#define CustomLocalizedString(key, comment) \
// if key exists in Localizable.strings
// use it
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
// else
// search it in KYLocalizable.strings
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:@"KYLocalizable"]
so I can just use CustomLocalizedString(<key>, <comment>)
in my project.
But how to check whether the key exists in Localizable.strings
or not?
Thanks in advance!!