You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the helpers are helpful in getting you up and running in 95% of use cases, they are not always exactly what everybody wants. In my use case, I still have a UIKit application that does custom localizations, so the generated String.init(localizable:locale:) method is not actually useful to me because I need to resolve the language in a different way.
It would be good in my project if I could just generate the definitions, and then write my own String.init(localizable:) method that works exactly how I need it instead of using the generated one.
While I'm aware that I could still do this by just creating a method with a different name, the concern that I have with leaving the default String.init(localizable:) method is that it makes things confusing and risks potentially using the wrong method. It would be better to eliminate it entirely.
The text was updated successfully, but these errors were encountered:
The idea is great, as it provides more possibilities for customizing the loading of strings, such as switching languages within the app. Switching languages within an app commonly requires specifying a bundle.
let fileName: String = isEnglish ? "en" : "fr"
let path = Bundle.main.path(forResource: fileName, ofType: "lproj")
let bundle = Bundle(path: path!)
let string = bundle?.localizedString(forKey: key, value: nil, table: "Localizable")
The code generated by xcstrings-tool can be broken down into two categories:
Definitions
xcstrings-tool/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift
Lines 50 to 124 in ca65df3
Helpers
xcstrings-tool/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift
Lines 211 to 219 in ca65df3
xcstrings-tool/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift
Lines 222 to 233 in ca65df3
xcstrings-tool/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift
Lines 336 to 411 in ca65df3
While the helpers are helpful in getting you up and running in 95% of use cases, they are not always exactly what everybody wants. In my use case, I still have a UIKit application that does custom localizations, so the generated
String.init(localizable:locale:)
method is not actually useful to me because I need to resolve the language in a different way.It would be good in my project if I could just generate the definitions, and then write my own
String.init(localizable:)
method that works exactly how I need it instead of using the generated one.While I'm aware that I could still do this by just creating a method with a different name, the concern that I have with leaving the default
String.init(localizable:)
method is that it makes things confusing and risks potentially using the wrong method. It would be better to eliminate it entirely.The text was updated successfully, but these errors were encountered: