Sources/OrgCore/Export/ExportDictionary.swift
126 lines · 7440 bytes
1import Foundation
2
3/// Org's translations of what exporters and clock tables write (ox.el `org-export-dictionary`,
4/// org-clock.el `org-clock-clocktable-language-setup`, Org 9.8.7), for `#+LANGUAGE` and
5/// `org-export-default-language`.
6public enum ExportDictionary {
7 public enum Encoding: String, Sendable { case html, ascii, utf8 = "utf-8", latex }
8
9 /// `org-export-translate`: the encoding's translation, else the language's default, else `term`.
10 public static func translate(_ term: String, language: String, encoding: Encoding) -> String {
11 guard let translations = dictionary[term]?[language] else { return term }
12 return translations[encoding.rawValue] ?? translations["default"] ?? term
13 }
14
15 /// `org-clock--translate`: `term` among File, L, Timestamp, Headline, Time, ALL, Total time,
16 /// File time and Clock summary at; the language is matched ignoring case.
17 public static func clockTable(_ term: String, language: String) -> String {
18 let terms = ["File", "L", "Timestamp", "Headline", "Time", "ALL", "Total time", "File time", "Clock summary at"]
19 guard let index = terms.firstIndex(of: term),
20 let row = clockTable.first(where: { $0.key.caseInsensitiveCompare(language) == .orderedSame })?.value,
21 index < row.count else { return term }
22 return row[index]
23 }
24
25 static let dictionary: [String: [String: [String: String]]] = [
26 "Table of Contents": [
27 "ar": ["default": "قائمة المحتويات"],
28 "ca": ["html": "Índex"],
29 "cs": ["default": "Obsah"],
30 "da": ["default": "Indhold"],
31 "de": ["default": "Inhaltsverzeichnis"],
32 "eo": ["default": "Enhavo"],
33 "es": ["ascii": "Indice", "html": "Índice", "default": "Índice"],
34 "et": ["default": "Sisukord"],
35 "fa": ["default": "فهرست"],
36 "fi": ["html": "Sisällysluettelo"],
37 "fr": ["ascii": "Sommaire", "default": "Table des matières"],
38 "hu": ["html": "Tartalomjegyzék"],
39 "is": ["default": "Efnisyfirlit"],
40 "it": ["default": "Indice"],
41 "ja": ["default": "目次", "html": "目次"],
42 "nl": ["default": "Inhoudsopgave"],
43 "no": ["default": "Innhold"],
44 "nb": ["default": "Innhold"],
45 "nn": ["default": "Innhald"],
46 "pl": ["default": "Spis treści", "html": "Spis treści"],
47 "pt_BR": ["html": "Índice", "utf-8": "Índice", "ascii": "Indice"],
48 "ro": ["default": "Cuprins"],
49 "ru": ["html": "Содержание", "utf-8": "Содержание"],
50 "sl": ["default": "Kazalo"],
51 "sv": ["default": "Innehåll"],
52 "tr": ["default": "İçindekiler"],
53 "uk": ["html": "Зміст", "utf-8": "Зміст"],
54 "zh-CN": ["html": "目录", "utf-8": "目录"],
55 "zh-TW": ["html": "目錄", "utf-8": "目錄"],
56 ],
57 "Figure %d:": [
58 "ar": ["default": "شكل %d:"],
59 "cs": ["default": "Obrázek %d:"],
60 "da": ["default": "Figur %d:"],
61 "de": ["default": "Abbildung %d:"],
62 "es": ["default": "Figura %d:"],
63 "et": ["default": "Joonis %d:"],
64 "fa": ["default": "شکل %d:"],
65 "fr": ["default": "Figure %d:", "html": "Figure %d :"],
66 "is": ["default": "Mynd %d:"],
67 "it": ["default": "Figura %d:"],
68 "ja": ["default": "図%d:", "html": "図%d:"],
69 "nl": ["default": "Figuur %d:", "html": "Figuur %d:"],
70 "no": ["default": "Illustrasjon %d:"],
71 "nb": ["default": "Illustrasjon %d:"],
72 "nn": ["default": "Illustrasjon %d:"],
73 "pl": ["default": "Obrazek %d:"],
74 "pt_BR": ["default": "Figura %d:"],
75 "ro": ["default": "Imaginea %d:"],
76 "ru": ["html": "Рис. %d.:", "utf-8": "Рис. %d.:"],
77 "sl": ["default": "Slika %d:"],
78 "sv": ["default": "Illustration %d:"],
79 "tr": ["default": "Şekil %d:"],
80 "zh-CN": ["html": "图%d ", "utf-8": "图%d "],
81 ],
82 "Footnotes": [
83 "ar": ["default": "الهوامش"],
84 "ca": ["html": "Peus de pàgina"],
85 "cs": ["default": "Poznámky pod čarou"],
86 "da": ["default": "Fodnoter"],
87 "de": ["html": "Fußnoten", "default": "Fußnoten"],
88 "eo": ["default": "Piednotoj"],
89 "es": ["ascii": "Notas al pie de pagina", "html": "Notas al pie de página", "default": "Notas al pie de página"],
90 "et": ["default": "Allmärkused", "html": "Allmärkused", "utf-8": "Allmärkused"],
91 "fa": ["default": "پانوشتها"],
92 "fi": ["default": "Alaviitteet"],
93 "fr": ["default": "Notes de bas de page"],
94 "hu": ["html": "Lábjegyzet"],
95 "is": ["html": "Aftanmálsgreinar"],
96 "it": ["html": "Note a piè di pagina"],
97 "ja": ["default": "脚注", "html": "脚注"],
98 "nl": ["default": "Voetnoten"],
99 "no": ["default": "Fotnoter"],
100 "nb": ["default": "Fotnoter"],
101 "nn": ["default": "Fotnotar"],
102 "pl": ["default": "Przypis"],
103 "pt_BR": ["html": "Notas de Rodapé", "default": "Notas de Rodapé", "ascii": "Notas de Rodape"],
104 "ro": ["default": "Note de subsol"],
105 "ru": ["html": "Сноски", "utf-8": "Сноски"],
106 "sl": ["default": "Opombe"],
107 "sv": ["default": "Fotnoter"],
108 "tr": ["default": "Dipnotlar"],
109 "uk": ["html": "Примітки", "utf-8": "Примітки"],
110 "zh-CN": ["html": "脚注", "utf-8": "脚注"],
111 "zh-TW": ["html": "腳註", "utf-8": "腳註"],
112 ],
113 ]
114
115 static let clockTable: [String: [String]] = [
116 "en": ["File", "L", "Timestamp", "Headline", "Time", "ALL", "Total time", "File time", "Clock summary at"],
117 "de": ["Datei", "E", "Zeitstempel", "Kopfzeile", "Dauer", "GESAMT", "Gesamtdauer", "Dateizeit", "Erstellt am"],
118 "es": ["Archivo", "N", "Fecha y hora", "Tarea", "Duración", "TODO", "Duración total", "Tiempo archivo", "Generado el"],
119 "fr": ["Fichier", "N", "Horodatage", "En-tête", "Durée", "TOUT", "Durée totale", "Durée fichier", "Horodatage sommaire à"],
120 "nl": ["Bestand", "N", "Tijdstip", "Rubriek", "Duur", "ALLES", "Totale duur", "Bestandstijd", "Klok overzicht op"],
121 "nn": ["Fil", "N", "Tidspunkt", "Overskrift", "Tid", "ALLE", "Total tid", "Filtid", "Tidsoversyn"],
122 "pl": ["Plik", "P", "Data i godzina", "Nagłówek", "Czas", "WSZYSTKO", "Czas całkowity", "Czas pliku", "Poddumowanie zegara na"],
123 "pt-BR": ["Arquivo", "N", "Data e hora", "Título", "Hora", "TODOS", "Hora total", "Hora do arquivo", "Resumo das horas em"],
124 "sk": ["Súbor", "L", "Časová značka", "Záhlavie", "Čas", "VŠETKO", "Celkový čas", "Čas súboru", "Časový súhrn pre"],
125 ]
126}