How to handle String input parameters(for Views) for localized translation

162 Views Asked by At

I have a problem with my localized translation. Handing a String to a view that has a translation in the localizable.strings file, will not get translated.

How can you pass a String to a View and translate it with localizable.strings.

TextFieldtView(label:"email", exampleInput: "[email protected]", paddingLeading: 30, paddingTrailing: 30, secure: false, widthLabel: 60, binding: $id)
Rectangle()
    .frame(width:widthLabel, height: 25)
    .offset(x:-110, y: -10)
    .foregroundColor(Color(.white))
    .overlay(Text(LocalizedStringKey("\(label)"))
    .foregroundColor(Color(.black)).opacity(1)
    .frame(height: 25)
    .padding(.bottom)
    .background(Rectangle().fill(.white).padding(.vertical, 10))
    .offset(x:-110, y: -4)
    )
Text(LocalizedStringKey("\(label)")
Text("\(label)")

Is how I tried to call it and pass it to the view but without success.

The label still shows as the name of the localized string not the translation itself. Thank you for your help!

0

There are 0 best solutions below