Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
930e9df
commit 104e7ce
Showing
5 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import SwiftUI | ||
|
||
/** | ||
This enum maps towards keys in `Localizable.strings` files. | ||
*/ | ||
public enum KKL10n: String, CaseIterable, Identifiable { | ||
|
||
case | ||
languageName, | ||
locale, | ||
`return`, | ||
space | ||
|
||
public var id: String { rawValue } | ||
var key: String { rawValue } | ||
|
||
var hasText: Bool { text != key } | ||
|
||
var text: String { | ||
let text = NSLocalizedString(key, bundle: .module, comment: "") | ||
let isMissing = text == key | ||
return isMissing ? "-" : text | ||
} | ||
} | ||
|
||
struct L10n_Previews: PreviewProvider { | ||
|
||
static var missing: [KKL10n] { | ||
KKL10n.allCases.filter { !$0.hasText } | ||
} | ||
|
||
static var previews: some View { | ||
NavigationView { | ||
List { | ||
if missing.count == 0 { | ||
Text("All done!") | ||
} else { | ||
Text("Missing translations:") | ||
} | ||
ForEach(KKL10n.allCases.filter { !$0.hasText }) { item in | ||
VStack(alignment: .leading) { | ||
Text("\(item.key)").font(.footnote) | ||
Text("\(item.text)") | ||
}.padding(.vertical, 4) | ||
} | ||
} | ||
} | ||
.environment(\.locale, Locale(identifier: "sv")) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/KeyboardKit/Resources/en.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
Localizable.strings | ||
KeyboardKit | ||
|
||
Created by Daniel Saidi on 2021-02-15. | ||
Copyright © 2021 Daniel Saidi. All rights reserved. | ||
*/ | ||
|
||
"locale" = "en"; | ||
"languageName" = "English"; | ||
|
||
"return" = "return"; | ||
"space" = "space"; |
13 changes: 13 additions & 0 deletions
13
Sources/KeyboardKit/Resources/sv.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
Localizable.strings | ||
KeyboardKit | ||
|
||
Created by Daniel Saidi on 2021-02-15. | ||
Copyright © 2021 Daniel Saidi. All rights reserved. | ||
*/ | ||
|
||
"locale" = "sv"; | ||
"languageName" = "Svenska"; | ||
|
||
"return" = "retur"; | ||
"space" = "mellanslag"; |