forked from vanniktech/multiplatform-locale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.swift
36 lines (30 loc) · 1.28 KB
/
App.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import SwiftUI
import multiplatform_locale
@main
struct LocaleApp : App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
VStack {
let currentLocaleString = Locales.shared.currentLocaleString()
Text("Current Locale: \(currentLocaleString)")
if let locale = multiplatform_locale.Locale.Companion.shared.fromOrNull(locale: currentLocaleString) {
Text("Google Play Store Locale: \(locale.googlePlayStoreLocale()?.description() ?? "/")")
Text("Apple App Store Locale: \(locale.appleAppStoreLocale()?.description() ?? "/")")
}
Text("Current Locale Strings: \(Locales.shared.currentLocaleStrings().joined(separator: ", "))")
.padding()
let countries = Country.values()
Text("All countries: \((0..<countries.size).compactMap { countries.get(index: $0) }.map { $0.displayName() }.joined(separator: ", "))")
.padding()
let languages = Language.values()
Text("All languages: \((0..<languages.size).compactMap { languages.get(index: $0) }.map { $0.displayName() }.joined(separator: ", "))")
.padding()
}
}
}