mac-cain13 / R.swift

Strong typed, autocompleted resources like images, fonts and segues in Swift projects
MIT License
9.5k stars 764 forks source link

Localization issue #873

Closed Nodirbek-Khudoyberdiev closed 9 months ago

Nodirbek-Khudoyberdiev commented 11 months ago

I want to change app language depending on users preference, but R Localization picks up phones language, how to change it globally.

tomlokhorst commented 9 months ago

There is no feature in R.swift for changing a language globally.

You can create localised instances of specific R sub structures like so:

let english = R.string(preferredLanguages: ["en"])
let french = R.string(preferredLanguages: ["fr"])
harryzjm commented 9 months ago

@Nodirbek-Khudoyberdiev

import RswiftResources

extension StringResource {
    public func callAsFunction() -> String {
        String(resource: self, preferredLanguages: [RunInfo.shared.currentLanguage.code])
    }
}

you can write like this, and reload table maybe.