kAiN
kAiN

Reputation: 2773

Month Name in another Language - SwiftUI

Hi all I need to display the current month name and to do that I am using Date() and formatted(.dateTime.month(.wide))

This way I can get the full name of the current month.

My problem is that the language in which I display it (even on the real device) is in English and I would need to display it in Italian as the whole app will be in Italian

A long time ago I didn't need to do any operations for automatic translation but now also on my device (iphone 13 pro max) I continue to view it in English

Is there something I forgot to do? Can you help me ?

var date: Date = Date()
date.formatted(.dateTime.month(.wide))
// Return January instead Gennaio

Upvotes: 0

Views: 898

Answers (1)

vadian
vadian

Reputation: 285079

There is also a locale modifier

Text(date.formatted(.dateTime
                    .month(.wide)
                    .locale(.init(identifier: "it_IT"))))

Upvotes: 1

Related Questions