R.swift
R.swift copied to clipboard
Change default language used for strings
Is there a more generic way to set the language used by strings?
I'm in a project that is recently adding i18n and was already using R.swift. I also know that we can do it so by replacing our strings from R.string.content.generatedName() to R.string.content.generatedName(preferredLanguages: ["es"])
The problem is we would need to change hundreds of strings manually. Instead, I would like to change hostingBundle or applicationLocale, which are both fileprivate static let. Could we have a method added to change one or both of those variables?
Prefer to add global settings for string language
did u find a solution for the above ?
Any update on this?
@SergioCardenas-Santex what did you do from your side ?
@mithilesh-parmar what did you do from you side?
@shadyk I changed all strings in my codebase.
- Made an extension on Array
extension Array where Element == String { static var preferredLanguageCode: [String] { [ // user preferred language code ] } }
- Changed all strings to
R.string.localizable.someString(preferredLanguages: .preferredLanguageCode)
@mithilesh-parmar I was trying to escape this solution 😞. Thanks anyway.
if the creators can change the hosting bundle's access control to public it will be great
Yeah I know if there was a way to change hosting bundle it would have been great. But I had to ship my app and could not find any solution so changed all the strings in codebase. @shadyk