I recently migrated my libraries into a SPM. My libraries contains also a UI stuff and pre-defines loclaized strings e.g.:
titleLabel.text = NSLoclaizedString("onboarding.page1.title", comment: "Blah blah blah")
I'm using a BartyCrouch for automating localization which ignores my libraries (expected). The real issue for me tho, is that when I put these in Localizable.strings manually, they're being ignored too
My question is: Is there any way how to localize those?
What I've tried, with no luck:
Inside my Swift Package:
public class LocalizableBridge {
public static let shared = LocalizableBridge()
public var bundle: Bundle = .main
}
final class MyViewController: UIViewController {
// some code...
private func setupLayout() {
loadingLabel.text = NSLocalizedString("plugin.loading-state.title", tableName: "Localizable", bundle: LocalizableBridge.shared.bundle, value: "plugin.loading-state.title", comment: "LOADING")
loadingLabel.textColor = .lightGray
activityIndicator.startAnimating()
}
// some code...
}
Inside my project:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appCoordinator: AppCoordinator?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// some code...
LocalizableBridge.shared.bundle = Bundle(identifier: "my.projects.bundle.id")!
// some code...
return true
}
}
Thanks guys in advance