Localize-Swift
Localize-Swift copied to clipboard
How to use in Objective-C ?
My project is mixing between swift and objective-c. I can't find the instruction to use with objective-c view controller.
This might be a little bit late but for anyone facing the same problem, I have a simple solution, its shouldn't be permanent solution as this should be integrated by marmelroy.
The Solution:
In the file
Pods/Pods/Localize-Swift/Sources/Localize.swift
Insert the following class function
open class func getLocalizedString(_ wantedString: String) -> String {
let localizedString = wantedString.localized()
return localizedString
}
Build the project again for the change to be implemented.
In your ViewController.h insert @import Localize_Swift;
In your ViewController.m, you can use
[Localize getLocalizedString: @"String"]
Example:
To get the localized string for "First Name" you can use
NSString *LocalizedFName = [Localize getLocalizedString: @"FName"];
Hi @MouMentos, I like this solution.
We should make it (or something similar) a part of the framework. I didn't realise this was an issue many people faced. Improving usage from ObjC will be a goal for the next release.
@MouMentos Thanks for your objective c localization solution.
I get an error
No known class method for selector 'getLocalizedString:'