Skip to content

Commit

Permalink
Initial localization of widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Oct 20, 2023
1 parent 6677a66 commit 7f93b32
Show file tree
Hide file tree
Showing 21 changed files with 409 additions and 159 deletions.
276 changes: 154 additions & 122 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions UnstoppableWallet/UnstoppableWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UnstoppableDomainsApiKey</key>
<string>${unstoppable_domains_api_key}</string>
<key>WallectConnectV2ProjectKey</key>
<key>UnstoppableDomainsApiKey</key>
<string>${unstoppable_domains_api_key}</string>
<key>WallectConnectV2ProjectKey</key>
<string>${wallet_connect_v2_project_key}</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<array>
<dict>
<key>INIntentCategory</key>
<string>generic</string>
<string>information</string>
<key>INIntentDescriptionID</key>
<string>OkcYOj</string>
<key>INIntentEligibleForWidgets</key>
Expand Down Expand Up @@ -176,7 +176,7 @@
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>Do</string>
<string>View</string>
</dict>
<dict>
<key>INIntentCategory</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WidgetKit
struct CoinPriceListEntry: TimelineEntry {
let date: Date
let mode: CoinPriceListMode
let sortType: String
let sortType: SortType
let maxItemCount: Int
let items: [Item]

Expand Down
15 changes: 2 additions & 13 deletions UnstoppableWallet/Widget/CoinPriceList/CoinPriceListProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct CoinPriceListProvider: IntentTimelineProvider {
return CoinPriceListEntry(
date: Date(),
mode: mode,
sortType: "Highest Cap",
sortType: .highestCap,
maxItemCount: count,
items: (1 ... count).map { index in
CoinPriceListEntry.Item(
Expand Down Expand Up @@ -93,7 +93,7 @@ struct CoinPriceListProvider: IntentTimelineProvider {
return CoinPriceListEntry(
date: Date(),
mode: mode,
sortType: title(sortType: sortType),
sortType: sortType,
maxItemCount: limit,
items: coins.map { coin in
CoinPriceListEntry.Item(
Expand All @@ -108,15 +108,4 @@ struct CoinPriceListProvider: IntentTimelineProvider {
}
)
}

private func title(sortType: SortType) -> String {
switch sortType {
case .highestCap, .unknown: return "Highest Cap"
case .lowestCap: return "Lowest Cap"
case .highestVolume: return "Highest Volume"
case .lowestVolume: return "Lowest Volume"
case .topGainers: return "Top Gainers"
case .topLosers: return "Top Losers"
}
}
}
26 changes: 19 additions & 7 deletions UnstoppableWallet/Widget/CoinPriceList/CoinPriceListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ struct CoinPriceListView: View {
VStack(spacing: 0) {
HStack(spacing: .margin16) {
Text(entry.mode.title)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.themeSubhead1)
.foregroundColor(.themeLeah)

Text(entry.sortType)
.frame(maxWidth: .infinity, alignment: .trailing)
Spacer()

Text(title(sortType: entry.sortType))
.font(.themeSubhead2)
.foregroundColor(.themeGray)
}
Expand Down Expand Up @@ -82,7 +82,7 @@ struct CoinPriceListView: View {
EmptyView()
}

Text("Your watchlist is empty.")
Text("watchlist.empty")
.multilineTextAlignment(.center)
.font(.themeSubhead2)
.foregroundColor(.themeGray)
Expand Down Expand Up @@ -117,22 +117,23 @@ struct CoinPriceListView: View {
VStack(spacing: 1) {
HStack(spacing: .margin16) {
Text(item.code.uppercased())
.frame(maxWidth: .infinity, alignment: .leading)
.font(.themeSubhead1)
.foregroundColor(.themeLeah)

Spacer()

Text(item.price)
.frame(maxWidth: .infinity, alignment: .trailing)
.font(.themeSubhead1)
.foregroundColor(.themeLeah)
}

HStack(spacing: .margin16) {
Text(item.name)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.themeSubhead2)
.foregroundColor(.themeGray)

Spacer()

Text(item.priceChange)
.font(.themeSubhead2)
.foregroundColor(item.priceChangeType.color)
Expand All @@ -153,4 +154,15 @@ struct CoinPriceListView: View {
.frame(width: .iconSize32, height: .iconSize32)
}
}

private func title(sortType: SortType) -> LocalizedStringKey {
switch sortType {
case .highestCap, .unknown: return "sort_type.highest_cap"
case .lowestCap: return "sort_type.lowest_cap"
case .highestVolume: return "sort_type.highest_volume"
case .lowestVolume: return "sort_type.lowest_volume"
case .topGainers: return "sort_type.top_gainers"
case .topLosers: return "sort_type.top_losers"
}
}
}
143 changes: 143 additions & 0 deletions UnstoppableWallet/Widget/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"sourceLanguage" : "en",
"strings" : {
"single_coin_price.description" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Displays price for certain coin"
}
}
}
},
"single_coin_price.title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Coin Price"
}
}
}
},
"sort_type.highest_cap" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Highest Cap"
}
}
}
},
"sort_type.highest_volume" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Highest Volume"
}
}
}
},
"sort_type.lowest_cap" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Lowest Cap"
}
}
}
},
"sort_type.lowest_volume" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Lowest Volume"
}
}
}
},
"sort_type.top_gainers" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Top Gainers"
}
}
}
},
"sort_type.top_losers" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Top Losers"
}
}
}
},
"top_coins.description" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Displays price for top coins"
}
}
}
},
"top_coins.title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Top Coins"
}
}
}
},
"watchlist.description" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Displays price coins in watchlist"
}
}
}
},
"watchlist.empty" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Your watchlist is empty"
}
}
}
},
"watchlist.title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Watchlist"
}
}
}
}
},
"version" : "1.0"
}
8 changes: 5 additions & 3 deletions UnstoppableWallet/Widget/Misc/CoinPriceListMode.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import SwiftUI

enum CoinPriceListMode {
case topCoins
case watchlist

var title: String {
var title: LocalizedStringKey {
switch self {
case .topCoins: return "Top Coins"
case .watchlist: return "Watchlist"
case .topCoins: return "top_coins.title"
case .watchlist: return "watchlist.title"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ struct SingleCoinPriceView: View {
Chart {
ForEach(chartPoints) { point in
LineMark(
x: .value("Date", point.date),
y: .value("Price", point.value)
x: .value(String("Date"), point.date),
y: .value(String("Price"), point.value)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions UnstoppableWallet/Widget/SingleCoinPriceWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct SingleCoinPriceWidget: Widget {
}
}
.contentMarginsDisabled()
.configurationDisplayName("Coin Price")
.description("Displays price for certain coin.")
.configurationDisplayName("single_coin_price.title")
.description("single_coin_price.description")
.supportedFamilies([
.systemSmall,
])
Expand Down
4 changes: 2 additions & 2 deletions UnstoppableWallet/Widget/TopCoinsWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct TopCoinsWidget: Widget {
}
}
.contentMarginsDisabled()
.configurationDisplayName("Top Coins")
.description("Displays price for top coins.")
.configurationDisplayName("top_coins.title")
.description("top_coins.description")
.supportedFamilies([
.systemSmall,
.systemMedium,
Expand Down
4 changes: 2 additions & 2 deletions UnstoppableWallet/Widget/WatchlistWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct WatchlistWidget: Widget {
}
}
.contentMarginsDisabled()
.configurationDisplayName("Watchlist")
.description("Displays price coins in watchlist.")
.configurationDisplayName("watchlist.title")
.description("watchlist.description")

.supportedFamilies([
.systemSmall,
Expand Down
8 changes: 8 additions & 0 deletions UnstoppableWallet/Widget/de.lproj/AppWidget.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"6ebp42" = "Selected Coin";
"8vJheC" = "Sort By";
"qHGyuo" = "Highest Cap";
"tVjZ7W" = "Lowest Cap";
"t6AKQ5" = "Highest Volume";
"C1LmDj" = "Lowest Volume";
"Rl3a0T" = "Top Gainers";
"x1kK4T" = "Top Losers";
8 changes: 8 additions & 0 deletions UnstoppableWallet/Widget/en.lproj/AppWidget.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"6ebp42" = "Selected Coin";
"8vJheC" = "Sort By";
"qHGyuo" = "Highest Cap";
"tVjZ7W" = "Lowest Cap";
"t6AKQ5" = "Highest Volume";
"C1LmDj" = "Lowest Volume";
"Rl3a0T" = "Top Gainers";
"x1kK4T" = "Top Losers";
8 changes: 8 additions & 0 deletions UnstoppableWallet/Widget/es.lproj/AppWidget.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"6ebp42" = "Selected Coin";
"8vJheC" = "Sort By";
"qHGyuo" = "Highest Cap";
"tVjZ7W" = "Lowest Cap";
"t6AKQ5" = "Highest Volume";
"C1LmDj" = "Lowest Volume";
"Rl3a0T" = "Top Gainers";
"x1kK4T" = "Top Losers";
8 changes: 8 additions & 0 deletions UnstoppableWallet/Widget/fr.lproj/AppWidget.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"6ebp42" = "Selected Coin";
"8vJheC" = "Sort By";
"qHGyuo" = "Highest Cap";
"tVjZ7W" = "Lowest Cap";
"t6AKQ5" = "Highest Volume";
"C1LmDj" = "Lowest Volume";
"Rl3a0T" = "Top Gainers";
"x1kK4T" = "Top Losers";
8 changes: 8 additions & 0 deletions UnstoppableWallet/Widget/ko.lproj/AppWidget.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"6ebp42" = "Selected Coin";
"8vJheC" = "Sort By";
"qHGyuo" = "Highest Cap";
"tVjZ7W" = "Lowest Cap";
"t6AKQ5" = "Highest Volume";
"C1LmDj" = "Lowest Volume";
"Rl3a0T" = "Top Gainers";
"x1kK4T" = "Top Losers";
Loading

0 comments on commit 7f93b32

Please sign in to comment.