swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.2k stars 10.32k forks source link

DatePicker has Time label non localised #64203

Closed vlondon closed 1 year ago

vlondon commented 1 year ago

Description When using SwiftUI's DatePicker with hourAndMinute and graphical date picker style it displays "Time" label that is not localised.

import SwiftUI

struct ContentView: View {

    @State private var date = Date.now

    var body: some View {
        DatePicker(
            "",
            selection: $date,
            in: date...,
            displayedComponents: [.date, .hourAndMinute]
        )
        .labelsHidden()
        .datePickerStyle(.graphical)
        .environment(\.locale, Locale.init(identifier: "de"))
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Steps to reproduce Create a DatePicker with following config and change locale to non-english one (for example: de, lt):

Expected behavior "Time" label to respect locale

Screenshot 2023-03-08 at 11 05 49

Environment

AnthonyLatsis commented 1 year ago

SwiftUI is a closed-source framework, so this issue is best reported using the feedback assistant.