Commit b4eed97410

b4eed97410ef6d2422dc27ebcfb7d1714193d46a

parent: 08ff64cf64

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-19 22:24 UTC

Localize command names in messages and key hints

- "isn't available on iPhone and iPad", "can't run here" and "needs an
  answer" messages are localizable and name the command in the app's
  language.
- Mac key hints show translated command titles and a translated "+prefix".
- l10n: the four new strings in de, fr, ja, es and pt-BR.

Layout: unified · split

Sources/OrgEditorAppKit/Modal.swift +1 −1
@@ -23,7 +23,7 @@ extension OrgEditor {
2323 case .pending(let keys):
2424 let context = editContext()
2525 let next = keymap.continuations(of: keys, mode: dispatcher.mode) { modalRuns($0, in: context) }.map { item in
26 (key: item.key.description, title: item.command.map { EditorCommands.command($0)?.title ?? $0 } ?? "+prefix")
26 (key: item.key.description, title: item.command.map { EditorCommands.command($0)?.localizedTitle ?? $0 } ?? "+prefix")
2727 }
2828 onKeysPending?(KeySequence.format(keys), next)
2929 return true
Sources/OrgEditorAppKit/OrgEditor.swift +1 −1
@@ -479,7 +479,7 @@ public final class OrgEditor: NSObject {
479479 case .pending(let keys):
480480 let context = context()
481481 let next = keymap.continuations(of: keys) { runs($0, in: context) }.map { item in
482 (key: item.key.description, title: item.command.map { EditorCommands.command($0)?.title ?? $0 } ?? "+prefix")
482 (key: item.key.description, title: item.command.map { EditorCommands.command($0)?.localizedTitle ?? $0 } ?? "+prefix")
483483 }
484484 onKeysPending?(KeySequence.format(keys), next)
485485 return true
Sources/Orgstar/AgendaView+Actions.swift +1 −1
@@ -247,7 +247,7 @@ extension AgendaView {
247247 private func performAt(_ entry: EntryRef, _ offset: Int, _ command: any OrgCommand, answers: [String: String] = [:]) -> String? {
248248 switch session.perform(command, path: entry.path, at: offset, expect: (offset, entry.line), answers: answers) {
249249 case .failed(let text): text
250 case .prompt: "\(command.title) needs an answer; run it on the entry itself"
250 case .prompt: String(localized: "\(CommandTitle.localized(command.title)) needs an answer; run it on the entry itself", comment: "A command run from the agenda that asks a question")
251251 default: nil
252252 }
253253 }
Sources/Orgstar/ColumnViewSheet.swift +1 −1
@@ -178,7 +178,7 @@ struct ColumnViewSheet: View {
178178 reply = prompt.initial ?? ""
179179 pending = (prompt, command, start, answers)
180180 default:
181 message = "\(command.title) can't run here"
181 message = String(localized: "\(CommandTitle.localized(command.title)) can't run here", comment: "A command that doesn't apply in column view")
182182 }
183183 focused = true
184184 }
Sources/Orgstar/Keys.swift +2 −1
@@ -27,7 +27,8 @@ struct EchoArea: View {
2727 ForEach(commands.keyHints, id: \.self) { hint in
2828 HStack(spacing: 8) {
2929 Text(hint.key).font(.system(.body, design: .monospaced)).foregroundStyle(.tint)
30 Text(hint.title).foregroundStyle(hint.title == "+prefix" ? .secondary : .primary).lineLimit(1)
30 Text(hint.title == "+prefix" ? String(localized: "+prefix", comment: "Key hint: the key starts a longer sequence") : hint.title)
31 .foregroundStyle(hint.title == "+prefix" ? .secondary : .primary).lineLimit(1)
3132 }
3233 }
3334 }
Sources/OrgstarMobile/AgendaScreen.swift +1 −1
@@ -850,7 +850,7 @@ struct AgendaScreen: View, Equatable {
850850 private func perform(_ command: any OrgCommand, _ path: String, _ offset: Int, answers: [String: String] = [:]) -> String? {
851851 switch session.perform(command, path: path, at: offset, expect: nil, answers: answers) {
852852 case .failed(let text): text
853 case .prompt: "\(command.title) needs an answer; run it on the entry itself"
853 case .prompt: String(localized: "\(CommandTitle.localized(command.title)) needs an answer; run it on the entry itself", comment: "A command run from the agenda that asks a question")
854854 case .external(let request): MobileEditor.unavailable(request, title: command.title)
855855 case .commit: nil
856856 }
Sources/OrgstarMobile/MobileEditor.swift +1 −1
@@ -342,7 +342,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
342342 /// Why a request the app doesn't handle did nothing: only table recalculation needs Emacs.
343343 static func unavailable(_ request: ExternalRequest, title: String) -> String {
344344 if case .emacsTable(_, _, _, let reason, _) = request { return "This table needs Emacs, which runs on the Mac: \(reason)." }
345 return "\(title) isn't available on iPhone and iPad."
345 return String(localized: "\(CommandTitle.localized(title)) isn't available on iPhone and iPad.", comment: "A command that runs only on the Mac")
346346 }
347347
348348 // MARK: - Commands by name and key
l10n/Localizable.xcstrings +140
@@ -154,6 +154,76 @@
154154 }
155155 }
156156 },
157 "%@ can't run here": {
158 "comment": "A command that doesn't apply in column view",
159 "localizations": {
160 "de": {
161 "stringUnit": {
162 "state": "translated",
163 "value": "%@ kann hier nicht ausgeführt werden"
164 }
165 },
166 "es": {
167 "stringUnit": {
168 "state": "translated",
169 "value": "%@ no se puede ejecutar aquí"
170 }
171 },
172 "fr": {
173 "stringUnit": {
174 "state": "translated",
175 "value": "Impossible d'exécuter %@ ici"
176 }
177 },
178 "ja": {
179 "stringUnit": {
180 "state": "translated",
181 "value": "%@はここでは実行できません"
182 }
183 },
184 "pt-BR": {
185 "stringUnit": {
186 "state": "translated",
187 "value": "Não é possível executar %@ aqui"
188 }
189 }
190 }
191 },
192 "%@ isn't available on iPhone and iPad.": {
193 "comment": "A command that runs only on the Mac",
194 "localizations": {
195 "de": {
196 "stringUnit": {
197 "state": "translated",
198 "value": "%@ ist auf iPhone und iPad nicht verfügbar."
199 }
200 },
201 "es": {
202 "stringUnit": {
203 "state": "translated",
204 "value": "%@ no está disponible en iPhone ni en iPad."
205 }
206 },
207 "fr": {
208 "stringUnit": {
209 "state": "translated",
210 "value": "%@ n'est pas disponible sur iPhone et iPad."
211 }
212 },
213 "ja": {
214 "stringUnit": {
215 "state": "translated",
216 "value": "%@はiPhoneとiPadでは利用できません。"
217 }
218 },
219 "pt-BR": {
220 "stringUnit": {
221 "state": "translated",
222 "value": "%@ não está disponível no iPhone e no iPad."
223 }
224 }
225 }
226 },
157227 "%@ late": {
158228 "localizations": {
159229 "de": {
@@ -188,6 +258,41 @@
188258 }
189259 }
190260 },
261 "%@ needs an answer; run it on the entry itself": {
262 "comment": "A command run from the agenda that asks a question",
263 "localizations": {
264 "de": {
265 "stringUnit": {
266 "state": "translated",
267 "value": "%@ braucht eine Antwort; führe den Befehl im Eintrag selbst aus"
268 }
269 },
270 "es": {
271 "stringUnit": {
272 "state": "translated",
273 "value": "%@ necesita una respuesta; ejecútalo en la propia entrada"
274 }
275 },
276 "fr": {
277 "stringUnit": {
278 "state": "translated",
279 "value": "%@ demande une réponse ; exécutez la commande dans l'entrée elle-même"
280 }
281 },
282 "ja": {
283 "stringUnit": {
284 "state": "translated",
285 "value": "%@は入力が必要です。エントリ上で直接実行してください"
286 }
287 },
288 "pt-BR": {
289 "stringUnit": {
290 "state": "translated",
291 "value": "%@ precisa de uma resposta; execute o comando na própria entrada"
292 }
293 }
294 }
295 },
191296 "%@ needs orgstar+": {
192297 "localizations": {
193298 "de": {
@@ -1239,6 +1344,41 @@
12391344 },
12401345 "shouldTranslate": false
12411346 },
1347 "+prefix": {
1348 "comment": "Key hint: the key starts a longer sequence",
1349 "localizations": {
1350 "de": {
1351 "stringUnit": {
1352 "state": "translated",
1353 "value": "+Präfix"
1354 }
1355 },
1356 "es": {
1357 "stringUnit": {
1358 "state": "translated",
1359 "value": "+prefijo"
1360 }
1361 },
1362 "fr": {
1363 "stringUnit": {
1364 "state": "translated",
1365 "value": "+préfixe"
1366 }
1367 },
1368 "ja": {
1369 "stringUnit": {
1370 "state": "translated",
1371 "value": "+プレフィックス"
1372 }
1373 },
1374 "pt-BR": {
1375 "stringUnit": {
1376 "state": "translated",
1377 "value": "+prefixo"
1378 }
1379 }
1380 }
1381 },
12421382 "+work-boss|LEVEL>2/!TODO": {
12431383 "shouldTranslate": false
12441384 },