I've implemented multilingual in my app and having multiple Localizable.strings
files created.
I have all strings key and value in Localizable.strings (Base)
file, as its default file read from all other languages if perticular string missing in specific language string file e.g. Localizable.strings (Japanese)
and some strings are missing in Japanese
file so I expecting to get string translation from Base
.
But it doesn't happen, thats my problem.
I faced the same issue and applied this solution:
DefaultEnglish.strings
)
E.g: "hello_key" = "Hello"
Localizable.strings
file
E.g: Japanese string: "hello_key" = "こんにちは"
Create String extension
extension String {
func localizedStringKey(bundle _: Bundle = .main, tableName: String = "Localizable") -> String {
return NSLocalizedString(self, tableName: tableName, value: "\(NSLocalizedString(self, tableName: "DefaultEnglish", bundle: .main, value: self, comment: ""))", comment: "")
} }
and set string "hello_key".localizedStringKey()