Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

There is also a locale modifier

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading