I would like to know if it is possible to use the app language on localization, and not the phone language?
I am talking about:
.configurationDisplayName("widget.name".localized())
and
.description("widget.description".localized())
I would like to know if it is possible to use the app language on localization, and not the phone language?
I am talking about:
.configurationDisplayName("widget.name".localized())
and
.description("widget.description".localized())
Yes, you can provide localised strings to both configurationDisplayName
and description
as they also accept LocalizedStringKey
parameters:
/// Sets the localized name shown for a widget when a user adds or edits
/// the widget.
///
/// - Parameter displayName: The key for the localized name to display.
/// - Returns: A widget configuration that includes a descriptive name for
/// the widget.
public func configurationDisplayName(_ displayNameKey: LocalizedStringKey) -> some WidgetConfiguration
/// Sets the localized description shown for a widget when a user adds or
/// edits the widget.
///
/// - Parameters:
/// - descriptionKey: The key for the localized description to display.
/// - Returns: A widget configuration with a description of the widget.
public func description(_ descriptionKey: LocalizedStringKey) -> some WidgetConfiguration
For more information see:
var disName: String {
LoadLocalizeSettings()
return "disName.key".localize()
}
perform like this:
.configurationDisplayName(disName)
If it doesn't work? you also can pod 'Localize'
func LoadLocalizeSettings() {
Localize.shared.update(provider: .strings)
Localize.shared.update(bundle: bundle)
Localize.shared.update(fileName: filename)
if let language = youWantThis {
update(language)
}
else {
update(.english)
}
}