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 { |
| 23 | case .pending(let keys): |
23 | case .pending(let keys): |
| 24 | let context = editContext() |
24 | let context = editContext() |
| 25 | let next = keymap.continuations(of: keys, mode: dispatcher.mode) { modalRuns($0, in: context) }.map { item in |
25 | 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") |
| 27 | } |
27 | } |
| 28 | onKeysPending?(KeySequence.format(keys), next) |
28 | onKeysPending?(KeySequence.format(keys), next) |
| 29 | return true |
29 | return true |
Sources/OrgEditorAppKit/OrgEditor.swift
+1 −1
| @@ -479,7 +479,7 @@ public final class OrgEditor: NSObject { |
| 479 | case .pending(let keys): |
479 | case .pending(let keys): |
| 480 | let context = context() |
480 | let context = context() |
| 481 | let next = keymap.continuations(of: keys) { runs($0, in: context) }.map { item in |
481 | 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") |
| 483 | } |
483 | } |
| 484 | onKeysPending?(KeySequence.format(keys), next) |
484 | onKeysPending?(KeySequence.format(keys), next) |
| 485 | return true |
485 | return true |
Sources/Orgstar/AgendaView+Actions.swift
+1 −1
| @@ -247,7 +247,7 @@ extension AgendaView { |
| 247 | private func performAt(_ entry: EntryRef, _ offset: Int, _ command: any OrgCommand, answers: [String: String] = [:]) -> String? { |
247 | private func performAt(_ entry: EntryRef, _ offset: Int, _ command: any OrgCommand, answers: [String: String] = [:]) -> String? { |
| 248 | switch session.perform(command, path: entry.path, at: offset, expect: (offset, entry.line), answers: answers) { |
248 | switch session.perform(command, path: entry.path, at: offset, expect: (offset, entry.line), answers: answers) { |
| 249 | case .failed(let text): text |
249 | 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") |
| 251 | default: nil |
251 | default: nil |
| 252 | } |
252 | } |
| 253 | } |
253 | } |
Sources/Orgstar/ColumnViewSheet.swift
+1 −1
| @@ -178,7 +178,7 @@ struct ColumnViewSheet: View { |
| 178 | reply = prompt.initial ?? "" |
178 | reply = prompt.initial ?? "" |
| 179 | pending = (prompt, command, start, answers) |
179 | pending = (prompt, command, start, answers) |
| 180 | default: |
180 | 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") |
| 182 | } |
182 | } |
| 183 | focused = true |
183 | focused = true |
| 184 | } |
184 | } |
Sources/Orgstar/Keys.swift
+2 −1
| @@ -27,7 +27,8 @@ struct EchoArea: View { |
| 27 | ForEach(commands.keyHints, id: \.self) { hint in |
27 | ForEach(commands.keyHints, id: \.self) { hint in |
| 28 | HStack(spacing: 8) { |
28 | HStack(spacing: 8) { |
| 29 | Text(hint.key).font(.system(.body, design: .monospaced)).foregroundStyle(.tint) |
29 | 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) |
| 31 | } |
32 | } |
| 32 | } |
33 | } |
| 33 | } |
34 | } |
Sources/OrgstarMobile/AgendaScreen.swift
+1 −1
| @@ -850,7 +850,7 @@ struct AgendaScreen: View, Equatable { |
| 850 | private func perform(_ command: any OrgCommand, _ path: String, _ offset: Int, answers: [String: String] = [:]) -> String? { |
850 | private func perform(_ command: any OrgCommand, _ path: String, _ offset: Int, answers: [String: String] = [:]) -> String? { |
| 851 | switch session.perform(command, path: path, at: offset, expect: nil, answers: answers) { |
851 | switch session.perform(command, path: path, at: offset, expect: nil, answers: answers) { |
| 852 | case .failed(let text): text |
852 | 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") |
| 854 | case .external(let request): MobileEditor.unavailable(request, title: command.title) |
854 | case .external(let request): MobileEditor.unavailable(request, title: command.title) |
| 855 | case .commit: nil |
855 | case .commit: nil |
| 856 | } |
856 | } |
Sources/OrgstarMobile/MobileEditor.swift
+1 −1
| @@ -342,7 +342,7 @@ final class MobileEditor: NSObject, DocumentBuffer { |
| 342 | /// Why a request the app doesn't handle did nothing: only table recalculation needs Emacs. |
342 | /// Why a request the app doesn't handle did nothing: only table recalculation needs Emacs. |
| 343 | static func unavailable(_ request: ExternalRequest, title: String) -> String { |
343 | static func unavailable(_ request: ExternalRequest, title: String) -> String { |
| 344 | if case .emacsTable(_, _, _, let reason, _) = request { return "This table needs Emacs, which runs on the Mac: \(reason)." } |
344 | 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") |
| 346 | } |
346 | } |
| 347 | |
347 | |
| 348 | // MARK: - Commands by name and key |
348 | // MARK: - Commands by name and key |
l10n/Localizable.xcstrings
+140
| @@ -154,6 +154,76 @@ |
| 154 | } |
154 | } |
| 155 | } |
155 | } |
| 156 | }, |
156 | }, |
| |
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 | }, |
| 157 | "%@ late": { |
227 | "%@ late": { |
| 158 | "localizations": { |
228 | "localizations": { |
| 159 | "de": { |
229 | "de": { |
| @@ -188,6 +258,41 @@ |
| 188 | } |
258 | } |
| 189 | } |
259 | } |
| 190 | }, |
260 | }, |
| |
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 | }, |
| 191 | "%@ needs orgstar+": { |
296 | "%@ needs orgstar+": { |
| 192 | "localizations": { |
297 | "localizations": { |
| 193 | "de": { |
298 | "de": { |
| @@ -1239,6 +1344,41 @@ |
| 1239 | }, |
1344 | }, |
| 1240 | "shouldTranslate": false |
1345 | "shouldTranslate": false |
| 1241 | }, |
1346 | }, |
| |
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 | }, |
| 1242 | "+work-boss|LEVEL>2/!TODO": { |
1382 | "+work-boss|LEVEL>2/!TODO": { |
| 1243 | "shouldTranslate": false |
1383 | "shouldTranslate": false |
| 1244 | }, |
1384 | }, |