Skip to content

Commit

Permalink
[Misc] Separate the Automatic handicap option (https://forums.online-…
Browse files Browse the repository at this point in the history
  • Loading branch information
honganhkhoa committed Nov 26, 2023
1 parent c4a4272 commit e8231d4
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 33 deletions.
197 changes: 182 additions & 15 deletions Surround/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,24 @@
}
},
"**Analysis mode** allows you and your opponent to test out variations during the game. It's like a separate virtual board where you can try things out." : {

"localizations" : {
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "**Chế độ phân tích** cho phép bạn và đối thủ chơi thử các biến thể trên bàn cờ giữa ván đấu."
}
}
}
},
"**Automatic** setting will determine the number of handicap stones based on your and your opponent's rank." : {

"localizations" : {
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Khi chọn **tự động**, hệ thống sẽ quyết định số quân chấp dựa trên chênh lệch cấp bậc giữa hai bên."
}
}
}
},
"**Automatic** setting will either assign white to the stronger player, or just assign randomly." : {
"localizations" : {
Expand Down Expand Up @@ -356,6 +370,17 @@
}
}
},
"%@ %@" : {
"comment" : "Time left on timer - more than 2 days",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "%1$@ %2$@"
}
}
}
},
"%@ %@ %@ %@ %@" : {
"comment" : "Duration string",
"localizations" : {
Expand Down Expand Up @@ -447,11 +472,22 @@
}
}
},
"%02d:%02d" : {
"comment" : "Time left - less than 1 hour.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "%1$02d:%2$02d"
}
}
}
},
"%lld" : {

},
"%lld captures" : {
"comment" : "show captures in player banner view\nSingleGameView - vary for plural",
"comment" : "SingleGameView - vary for plural\nshow captures in player banner view",
"localizations" : {
"en" : {
"variations" : {
Expand Down Expand Up @@ -531,6 +567,23 @@
}
}
},
"%lld days left" : {
"comment" : "Time left - more than 2 days left, days part",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "%lld days"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "%lld ngày"
}
}
}
},
"%lld hours" : {
"comment" : "Duration - hours part, long format",
"localizations" : {
Expand Down Expand Up @@ -747,6 +800,18 @@
}
}
}
},
"vi" : {
"variations" : {
"plural" : {
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "%lld Quân"
}
}
}
}
}
}
},
Expand Down Expand Up @@ -812,6 +877,52 @@
"%lldh" : {
"comment" : "Duration - hours part, short format"
},
"%lldh %02dm" : {
"comment" : "Time left - 1 hour to 1 day.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "%1$lldh %2$02dm"
}
}
}
},
"%lldh left" : {
"comment" : "Time left - more than 2 days left, hours part",
"localizations" : {
"en" : {
"variations" : {
"plural" : {
"one" : {
"stringUnit" : {
"state" : "translated",
"value" : "%lldh"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "%lldhs"
}
}
}
}
},
"vi" : {
"variations" : {
"plural" : {
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "%lld giờ"
}
}
}
}
}
}
},
"%lldk" : {
"comment" : "formattedRank - kyu - short format",
"localizations" : {
Expand Down Expand Up @@ -1274,6 +1385,12 @@
"state" : "translated",
"value" : "自動"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tự động"
}
}
}
},
Expand All @@ -1293,6 +1410,16 @@
}
}
},
"Automatically decide handicap" : {
"localizations" : {
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tự động chọn số quân chấp"
}
}
}
},
"B+" : {

},
Expand Down Expand Up @@ -1790,6 +1917,16 @@
}
}
},
"Create challenge" : {
"localizations" : {
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tạo thách đấu"
}
}
}
},
"Currently, **Surround** only supports a small subset of features on OGS, and I plan to implement support for more features gradually. Following the spirit of OGS, most features are available for free, but I would really appreciate if you decide to support the development of the app." : {

},
Expand Down Expand Up @@ -2012,6 +2149,12 @@
"state" : "translated",
"value" : "対局名:"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tên ván: "
}
}
}
},
Expand Down Expand Up @@ -2597,6 +2740,29 @@
}
}
},
"No handicap" : {
"comment" : "NewGameView handicap seletion, no handicap",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "None"
}
},
"ja" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "なし"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Không"
}
}
}
},
"No players found." : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -2652,17 +2818,6 @@
}
}
},
"None" : {
"comment" : "NewGameView handicap seletion, no handicap",
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "なし"
}
}
}
},
"Note to yourself" : {

},
Expand Down Expand Up @@ -2778,6 +2933,12 @@
"state" : "translated",
"value" : "その他"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Khác"
}
}
}
},
Expand Down Expand Up @@ -4099,7 +4260,7 @@
}
},
"Waiting for opponent: %lld games " : {
"comment" : "HomeView - vary for plural\nNewGameView - vary for plural",
"comment" : "NewGameView - vary for plural\nHomeView - vary for plural",
"localizations" : {
"en" : {
"variations" : {
Expand Down Expand Up @@ -4312,6 +4473,12 @@
"state" : "translated",
"value" : "非公開対局相手を選択して下さい。又は、対局要請を公開して下さい。"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Bạn chưa chọn đối thủ."
}
}
}
},
Expand Down
17 changes: 8 additions & 9 deletions Surround/Services/TimeUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,21 @@ class TimeUtilities {
secondsLeft -= minutesLeft * 60

if daysLeft > 1 {
var result = "\(daysLeft) days"
let daysString = String(localized: "\(daysLeft) days left", comment: "Time left - more than 2 days left, days part")
let hoursString = String(localized: "\(hoursLeft)h left", comment: "Time left - more than 2 days left, hours part")
if hoursLeft > 0 {
result += " \(hoursLeft)h"
}
if hoursLeft > 1 {
result += "s"
return String(localized: "\(daysString) \(hoursString)", comment: "Time left on timer - more than 2 days")
} else {
return daysString
}
return result
} else {
if daysLeft == 1 {
return "\(hoursLeft + 24)h"
return String(localized: "\(hoursLeft + 24)h left", comment: "Time left - 1 day to 2 days.")
} else {
if hoursLeft >= 1 {
return String(format: "%dh %02dm", hoursLeft, minutesLeft)
return String(localized: "\(hoursLeft)h \(minutesLeft, specifier: "%02d")m", comment: "Time left - 1 hour to 1 day.")
} else {
return String(format: "%02d:%02d", minutesLeft, secondsLeft)
return String(localized: "\(minutesLeft, specifier: "%02d"):\(secondsLeft, specifier: "%02d")", comment: "Time left - less than 1 hour.")
}
}
}
Expand Down
23 changes: 14 additions & 9 deletions Surround/Views/NewGameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,19 +345,24 @@ struct CustomGameForm: View {
}
}
Divider()
Stepper(value: $handicap, in: -1...(isRanked ? 9 : 36)) {
(Text("Handicap: ").bold() + Text(
handicap == -1 ? String(localized: "Automatic", comment: "NewGameView handicap selection, automatic handicap") :
handicap == 0 ? String(localized: "None", comment : "NewGameView handicap seletion, no handicap") :
String(localized: "\(handicap) Stones", comment: "NewGameView handicap selection - vary for plural")
))
.font(.subheadline)
Toggle(isOn: Binding ( get: { handicap == -1 }, set: { handicap = ($0 ? -1 : 0) })) {
Text("Automatically decide handicap")
}
if handicap == -1 {
if handicap > -1 {
Stepper(value: $handicap, in: 0...(isRanked ? 9 : 36)) {
(Text("Handicap: ").bold() + Text(
handicap == -1 ? String(localized: "Automatic", comment: "NewGameView handicap selection, automatic handicap") :
handicap == 0 ? String(localized: "No handicap", comment : "NewGameView handicap seletion, no handicap") :
String(localized: "\(handicap) Stones", comment: "NewGameView handicap selection - vary for plural")
))
.font(.subheadline)
}
} else {
(Text("**Automatic** setting will determine the number of handicap stones based on your and your opponent's rank."))
.font(.caption)
.leadingAlignedInScrollView()
}
Divider()
Toggle(isOn: $automaticColor) {
Text("Automatically assign stone colors").font(.subheadline)
.leadingAlignedInScrollView()
Expand Down Expand Up @@ -598,7 +603,7 @@ struct CustomGameForm: View {
Spacer().frame(height: 15)
ProgressView()
} else {
MainActionButton(label: "Create challenge", disabled: createButtonDisabled, action: createChallenge)
MainActionButton(label: String(localized: "Create challenge"), disabled: createButtonDisabled, action: createChallenge)
if !isOpen && opponent == nil {
Text("You need to choose an opponent or make the challenge open.")
.font(.caption)
Expand Down

0 comments on commit e8231d4

Please sign in to comment.