Repository navigation
Expand file tree
/
Copy pathi18n.py
More file actions
421 lines (399 loc) · 23.3 KB
/
Copy pathi18n.py
File metadata and controls
421 lines (399 loc) · 23.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
"""The languages dog_vision's window speaks.
As in gettext, a text is looked up by its English wording, and a text missing from
a language's catalogue stays English; that is how source citations pass through
unchanged. Adding a language is adding an entry to LANGUAGES.
"""
import dataclasses
import locale
import os
import sys
CZECH = {
# Window
"Dog vision": "Psí vidění",
"Species": "Druh",
"Selected species": "Vybraný druh",
"Adaptation to scene [%]": "Adaptace na scénu [%]",
"Simulation strength [%]": "Síla simulace [%]",
"Simulation": "Simulace",
"Colour saturation": "Sytost barev",
"Fixed by the projection": "Daná projekcí",
"Matched to discrimination (RNL)": "Podle rozlišování (RNL)",
"Acuity": "Ostrost",
"Blur to the species' acuity": "Rozostřit na ostrost druhu",
"Image spans [degrees]": "Šířka záběru [°]",
"View": "Zobrazení",
"Side by side (m)": "Vedle sebe (m)",
"Left image": "Levý obraz",
"Map of differences (d)": "Mapa rozdílů (d)",
"Reset (r)": "Obnovit (r)",
"Save snapshot": "Uložit snímek",
"Saved {name}": "Uloženo: {name}",
"No frame yet": "Zatím žádný snímek",
"Record video": "Nahrávat video",
"Recording {name}: {time}": "Nahrávám {name}: {time}",
"Finishing {name}": "Dokončuji {name}",
"Recording failed: {error}": "Nahrávání selhalo: {error}",
"Language": "Jazyk",
"File": "Soubor",
"Camera {index}": "Kamera {index}",
"Open file…": "Otevřít soubor…",
"Camera": "Kamera",
"Convert file": "Převést soubor",
"Quit": "Ukončit",
"Side panel": "Boční panel",
"Side by side": "Vedle sebe",
"Map of differences": "Mapa rozdílů",
"Copy": "Kopírovat",
"Select all": "Vybrat vše",
"Open a photo or a video": "Otevřít fotku nebo video",
"Photos and videos": "Fotky a videa",
"All files": "Všechny soubory",
"Cannot open {name} as a photo or a video": "{name} nejde otevřít jako fotka ani jako video",
"Cannot open camera {index}": "Kameru {index} nejde otevřít",
"Output folder…": "Výstupní složka…",
"Folder for snapshots and recordings": "Složka pro snímky a nahrávky",
"Snapshots and recordings go to {folder}": "Snímky a nahrávky se ukládají do {folder}",
"Converted files into the output folder": "Převedené soubory do výstupní složky",
"Cannot save the settings: {error}": "Nastavení nejde uložit: {error}",
"Cannot save snapshot: {error}": "Snímek nejde uložit: {error}",
"Converting: {share}": "Převádím: {share}",
"Wrote {name}": "Zapsáno: {name}",
"Wrote {name}: {description}": "Zapsáno: {name}, {description}",
"Conversion failed: {error}": "Převod selhal: {error}",
"{format} ({encoder}), with the original sound": "{format} ({encoder}), s původním zvukem",
"{format} ({encoder}); the original has no sound": "{format} ({encoder}); originál nemá zvuk",
"{format} ({encoder}), without sound: ffmpeg is not installed": (
"{format} ({encoder}), bez zvuku: ffmpeg není nainstalovaný"
),
"{format} ({encoder})": "{format} ({encoder})",
# Caption
"original": "originál",
"red: noticeably different ({share} of pixels)": "červeně: znatelně odlišné ({share} pixelů)",
# Species facts
"{0}%": "{0} %",
"{0}%–{1}%": "{0}–{1} %",
"Colour vision": "Barevné vidění",
"monochromat": "monochromat",
"dichromat": "dichromat",
"trichromat": "trichromat",
"{kind}, 1 cone type": "{kind}, 1 typ čípků",
"{kind}, {n} cone types": "{kind}, {n} typy čípků",
"Cone peaks": "Maxima čípků",
"S cones": "Čípky S",
"{share} of cones": "{share} čípků",
"L : M cones": "Poměr L : M",
"Neutral point": "Neutrální bod",
"RNL scale": "Škála RNL",
"no colour axis": "žádná barevná osa",
"(sees only grey)": "(vidí jen šeď)",
"{gains} of fixed": "{gains} vůči projekci",
" and ": " a ",
"assumed": "předpoklad",
"not found measured;": "měření nenalezeno;",
"left sharp": "ponecháno ostré",
"{value} c/deg": "{value} c/°",
"{across} c/deg side by side,": "{across} c/° vodorovně,",
"{up} one above another": "{up} svisle",
# Notes attached to a source in dog_vision's tables
"L shifted 10 nm, see text": "L posunutý o 10 nm, viz text",
"M shifted 10 nm, see text": "M posunutý o 10 nm, viz text",
"Jacobs et al. 1996, S assumed": "Jacobs et al. 1996, S předpokládán",
"Sumita et al. 2013, 11.7 to 14": "Sumita et al. 2013, 11,7 až 14",
"Jacobs, Birch & Blakeslee 1982, 1.8 to 3.8": "Jacobs, Birch & Blakeslee 1982, 1,8 až 3,8",
"Nature Neuroscience 2024, about 60": "Nature Neuroscience 2024, asi 60",
"Hanke & Dehnhardt 2009, in air": "Hanke & Dehnhardt 2009, na vzduchu",
"Herman et al. 1975, 8.2 arcmin stripes": "Herman et al. 1975, pruhy 8,2′",
# Descriptions shown while the pointer rests on a label
(
"How many kinds of cone the species has, and so how many independent colour signals its eye sends."
"\n\nA trichromat, like us, has three. A camera records nothing that would merge for it, so its image"
" stays as it is unless Colour saturation is matched to discrimination."
"\n\nA dichromat has two. Colours that differ only along one direction look the same to it, and the"
" simulation shows them on the blue–yellow axis."
"\n\nA cone monochromat has one, and sees shades of grey."
): (
"Kolik druhů čípků živočich má, a tedy kolik nezávislých barevných signálů jeho oko vysílá."
"\n\nTrichromat jako my má tři. Kamera nezaznamená nic, co by mu splývalo, takže jeho obraz zůstane"
" beze změny, pokud Sytost barev není nastavená Podle rozlišování."
"\n\nDichromat má dva. Barvy, které se liší jen v jednom směru, pro něj vypadají stejně, a simulace je"
" ukáže na ose modrá–žlutá."
"\n\nČípkový monochromat má jeden a vidí odstíny šedi."
),
(
"The wavelength each kind of cone is most sensitive to: S for short, M for middle and L for long"
" wavelengths. A dichromat's longer cone is listed as L whatever its source calls it."
"\n\nThe study the peaks are taken from is in brackets; the README lists every source in full under"
" References. A note after the citation marks a value that is not simply measured, such as a cone"
" shifted on purpose or one assumed."
"\n\nEach cone is modelled from its peak alone, with the pigment template of Govardovskii et al."
" (2000). Its sensitivity is about 100 nm wide at half height, which is why a shift of a few"
" nanometres between species changes little."
"\n\nA human's cones peak at 420.7, 530.3 and 558.9 nm."
): (
"Vlnová délka, na kterou je každý druh čípku nejcitlivější: S pro krátké, M pro střední a L pro"
" dlouhé vlnové délky. Delší čípek dichromata je uveden jako L, ať ho zdroj nazývá jakkoli."
"\n\nV závorce je studie, ze které jsou maxima převzata; README uvádí všechny zdroje celé v části"
" References. Poznámka za citací označuje hodnotu, která není prostě změřená, třeba záměrně posunutý"
" čípek nebo předpokládanou hodnotu."
"\n\nKaždý čípek je modelován jen z tohoto maxima, šablonou pigmentu, kterou popsali Govardovskii et"
" al. (2000). Jeho citlivost je v polovině výšky široká asi 100 nm, a proto posun o pár nanometrů"
" mezi druhy změní málo."
"\n\nLidské čípky mají maxima 420,7; 530,3 a 558,9 nm."
),
(
"The share of all cones that are S cones, with its source. Where the source reports a range across"
" the retina, the middle of it is used."
"\n\nOnly the RNL colour saturation uses it: the fewer cones of a kind, the noisier their signal, and"
" the larger a colour difference along that cone's axis must be to be noticed."
"\n\n\"Assumed\" means no measurement was found, and 10 % is used, the middle of what the measured"
" species span."
): (
"Podíl čípků S mezi všemi čípky, se zdrojem. Kde zdroj uvádí rozpětí napříč sítnicí, použije se jeho"
" střed."
"\n\nPoužívá ho jen sytost barev Podle rozlišování (RNL): čím méně čípků daného druhu, tím zašuměnější"
" je jejich signál a tím větší musí být barevný rozdíl podél jejich osy, aby byl postřehnutelný."
"\n\n„Předpoklad“ znamená, že měření nebylo nalezeno a použije se 10 %, střed rozpětí změřených druhů."
),
(
"How many L cones a trichromat has for every M cone. Only the RNL colour saturation uses it."
"\n\nHumans with normal colour vision range from about twice as many L as M cones to the reverse"
" (Roorda & Williams 1999), so every trichromat is given 1 : 1, and it is marked as assumed."
): (
"Kolik čípků L má trichromat na každý čípek M. Používá ho jen sytost barev Podle rozlišování (RNL)."
"\n\nLidé s normálním barevným viděním mají od zhruba dvojnásobku čípků L oproti M až po opačný poměr"
" (Roorda & Williams 1999), proto má každý trichromat 1 : 1 a hodnota je označená jako předpoklad."
),
(
"The wavelength of pure spectral light that a dichromat cannot tell from white. Shorter wavelengths"
" look bluish to it, longer ones yellowish."
"\n\nThe value is the model's, computed from the cone peaks. For the dog it matches the measured"
" neutral point of about 480 nm (Neitz, Geist & Jacobs 1989). For a human deuteranope it falls well"
" short of the measured 505 nm, probably because the model ignores the lens and the macular pigment."
): (
"Vlnová délka čistého spektrálního světla, které dichromat nerozezná od bílé. Kratší vlnové délky mu"
" připadají namodralé, delší nažloutlé."
"\n\nHodnota pochází z modelu, spočítaná z maxim čípků. U psa odpovídá změřenému neutrálnímu bodu kolem"
" 480 nm (Neitz, Geist & Jacobs 1989). U lidského deuteranopa vychází výrazně pod změřenými 505 nm,"
" nejspíš proto, že model nezahrnuje čočku ani makulární pigment."
),
(
"How much the RNL colour saturation changes saturation compared with the fixed one. Below 1 the"
" species tells colours apart worse than we do, above 1 better."
"\n\nIt comes from the receptor noise limited model of Vorobyev & Osorio (1998), which counts"
" just-noticeable differences from each cone's noise, set by the share of cones of its kind. The"
" output is rescaled until a human looking at it counts as many differences as the animal would. A"
" trichromat has two colour axes and so two factors; a monochromat has none."
"\n\nIt assumes the animal's cones are as noisy as ours, which is measured for almost no mammal."
): (
"O kolik sytost barev Podle rozlišování (RNL) mění sytost oproti sytosti dané projekcí. Pod 1"
" rozlišuje druh barvy hůř než my, nad 1 lépe."
"\n\nVychází z modelu šumem omezených receptorů (receptor noise limited, Vorobyev & Osorio 1998), který"
" počítá právě postřehnutelné rozdíly ze šumu každého čípku, daného podílem čípků jeho druhu. Výstup"
" se přeškáluje, dokud člověk, který se na něj dívá, nenapočítá tolik rozdílů, kolik by jich"
" napočítal živočich. Trichromat má dvě barevné osy, a tedy dva faktory; monochromat žádný."
"\n\nPředpokládá, že čípky živočicha jsou stejně zašuměné jako naše, což je změřené skoro u žádného"
" savce."
),
(
"The finest stripes the species resolves, in cycles per degree: pairs of one dark and one light"
" stripe within one degree of view. A human resolves about 72."
"\n\nWith Blur to the species' acuity checked, detail finer than that is removed, as AcuityView does"
" (Caves & Johnsen 2018)."
"\n\nCattle resolve detail side by side better than one above another, since their pupil is a"
" horizontal oval. A species without a measurement is left sharp."
): (
"Nejjemnější pruhy, které druh rozliší, v cyklech na stupeň: dvojice jednoho tmavého a jednoho"
" světlého pruhu v jednom stupni zorného pole. Člověk rozliší asi 72."
"\n\nPři zaškrtnutém Rozostřit na ostrost druhu se odstraní detail jemnější než tato hranice, stejně"
" jako to dělá AcuityView (Caves & Johnsen 2018)."
"\n\nSkot rozliší detail vedle sebe lépe než nad sebou, protože má zornici ve tvaru vodorovného oválu."
" Druh bez měření zůstane ostrý."
),
(
"The animal to simulate, with its kind of colour vision in brackets."
"\n\nMost dichromatic mammals look much alike: they share the same two cone genes, tuned a few tens of"
" nanometres apart at most. The large steps are between kinds of colour vision, not between species"
" of one kind."
): (
"Živočich, jehož vidění se simuluje, s typem barevného vidění v závorce."
"\n\nVětšina dichromatických savců vypadá velmi podobně: mají stejné dva geny pro čípky, naladěné"
" nanejvýš pár desítek nanometrů od sebe. Velké skoky jsou mezi typy barevného vidění, ne mezi druhy"
" jednoho typu."
),
(
"How far the cones adapt to the scene instead of to daylight."
"\n\nAt 0 the eye is adapted to daylight, so a scene lit by a warm sunset looks warm. At 100 each"
" cone's signal is scaled so that the scene's average colour becomes neutral, the way an eye that has"
" been in that light for a while stops noticing its cast (von Kries adaptation to a \"grey world\")."
): (
"Jak moc se čípky přizpůsobí scéně místo dennímu světlu."
"\n\nPři 0 je oko adaptované na denní světlo, takže scéna osvětlená teplým západem slunce vypadá teple."
" Při 100 se signál každého čípku přeškáluje tak, aby průměrná barva scény byla neutrální, podobně"
" jako oko, které je v tom světle už chvíli, přestane jeho nádech vnímat (von Kriesova adaptace na"
" „šedý svět“)."
),
(
"Blends the simulation with the original image: 0 shows the original, 100 the full simulation."
"\n\nIn between, the colours the animal cannot tell apart are only partly merged."
): (
"Míchá simulaci s původním obrazem: 0 ukáže originál, 100 plnou simulaci."
"\n\nMezi tím barvy, které živočich nerozliší, splynou jen zčásti."
),
(
"Colours the animal cannot tell apart are merged, and the rest keep the saturation the projection"
" happens to give them."
"\n\nThe merging says which colours look alike, but not how vivid the others look: that has no natural"
" scale. For a trichromat nothing merges, so this leaves the image as it is."
): (
"Barvy, které živočich nerozliší, splynou a ostatní si ponechají sytost, jakou jim projekce zrovna"
" dá."
"\n\nSplynutí říká, které barvy vypadají stejně, ale ne, jak živé jsou ostatní: to nemá přirozené"
" měřítko. U trichromata nesplyne nic, takže obraz zůstane beze změny."
),
(
"Saturation is rescaled so that a human looking at the image can tell as many colour steps apart as"
" the animal can in the scene. An animal that tells colours apart worse than we do gets paler"
" colours."
"\n\nThe steps are counted by the receptor noise limited model, from the share of each kind of cone;"
" the factors are under RNL scale in Selected species."
"\n\nIt assumes the animal's cones are as noisy as ours, and it is matched near grey, so strongly"
" saturated colours are extrapolated."
): (
"Sytost se přeškáluje tak, aby člověk, který se na obraz dívá, rozlišil stejně barevných kroků, kolik"
" by jich živočich rozlišil ve scéně. Živočich, který rozlišuje barvy hůř než my, dostane bledší"
" barvy."
"\n\nKroky počítá model šumem omezených receptorů (RNL) z podílu jednotlivých druhů čípků; faktory jsou"
" v řádku Škála RNL v panelu Vybraný druh."
"\n\nPředpokládá, že čípky živočicha jsou stejně zašuměné jako naše, a je sladěný poblíž šedé, takže"
" výrazně syté barvy jsou extrapolované."
),
(
"Removes the detail finer than the species resolves, with a blur matching its measured acuity (Acuity"
" in Selected species)."
"\n\nThe blur shows only if the image has more pixels per degree than the species resolves. A camera"
" image 640 pixels wide spanning 60° has about 11 pixels per degree, so a dog's blur is under half a"
" pixel and invisible, while a large photo shows it clearly."
): (
"Odstraní detail jemnější, než druh rozliší, rozostřením podle jeho změřené ostrosti (řádek Ostrost v"
" panelu Vybraný druh)."
"\n\nRozostření je vidět, jen když má obraz víc pixelů na stupeň, než druh rozliší. Obraz z kamery"
" široký 640 pixelů, který zabírá 60°, má asi 11 pixelů na stupeň, takže rozostření psa je menší než"
" půl pixelu a neviditelné, kdežto velká fotka ho ukáže zřetelně."
),
(
"How many degrees of view the image spans from left to right. The blur is set per degree, so this"
" decides how many pixels wide it is: halving the angle halves the blur."
"\n\n60° is typical of a camera. The result is right when the image is seen at that same angle; seen"
" smaller, your own acuity blurs it further."
): (
"Kolik stupňů zorného pole obraz zabírá zleva doprava. Rozostření se určuje na stupeň, takže tohle"
" rozhoduje, kolik pixelů je široké: poloviční úhel znamená poloviční rozostření."
"\n\n60° je obvyklé u kamery. Výsledek sedí, když se na obraz díváte pod stejným úhlem; zmenšený ho"
" vaše vlastní ostrost rozostří ještě víc."
),
(
"Shows a second image to the left of the simulation: the original, or another species chosen under"
" Left image. Unchecked, only the simulation is shown."
): (
"Ukáže vlevo od simulace druhý obraz: originál, nebo jiný druh vybraný v poli Levý obraz."
" Nezaškrtnuté ukáže jen simulaci."
),
(
"What the left image shows: the original, or another species rendered with the same settings, so that"
" two animals can be compared directly."
): (
"Co ukazuje levý obraz: originál, nebo jiný druh vykreslený se stejným nastavením, aby šlo dva"
" živočichy přímo porovnat."
),
(
"Adds a third image: grey where the left and right images look the same, red where they differ by"
" more than one just-noticeable difference, deeper the larger the difference."
"\n\nIt compares the two images as a human sees them, in CIELAB, where one just-noticeable difference"
" is about ΔE 2.3 (Mahy et al. 1994), so it catches differences in colour and in sharpness alike."
"\n\nIt measures the two renderings, each already reduced to what its animal can tell apart. The"
" threshold is an average, so the edge of the red region is approximate."
): (
"Přidá třetí obraz: šedě tam, kde levý a pravý obraz vypadají stejně, červeně tam, kde se liší o víc"
" než jeden právě postřehnutelný rozdíl, a tím sytěji, čím je rozdíl větší."
"\n\nPorovnává oba obrazy tak, jak je vidí člověk, v prostoru CIELAB, kde je jeden právě postřehnutelný"
" rozdíl asi ΔE 2,3 (Mahy et al. 1994), takže zachytí rozdíly v barvě i v ostrosti."
"\n\nMěří dvě vykreslení, každé už omezené na to, co jeho živočich rozliší. Práh je průměrný, takže"
" okraj červené oblasti je přibližný."
),
(
"Returns every control to the values given on the command line."
): (
"Vrátí všechny ovládací prvky na hodnoty zadané na příkazové řádce."
),
}
CZECH_SPECIES = {
"dog": "pes",
"cat": "kočka",
"horse": "kůň",
"cow": "kráva",
"sheep": "ovce",
"goat": "koza",
"pig": "prase",
"fallow-deer": "daněk",
"white-tailed-deer": "jelenec běloocasý",
"guinea-pig": "morče",
"tree-squirrel": "veverka",
"ground-squirrel": "sysel kalifornský",
"ferret": "fretka",
"protanope": "protanop",
"deuteranope": "deuteranop",
"human": "člověk",
"protanomalous": "protanomál",
"deuteranomalous": "deuteranomál",
"macaque": "makak",
"howler-monkey": "vřešťan",
"marmoset-female": "kosman, samice",
"harbour-seal": "tuleň obecný",
"bottlenose-dolphin": "delfín skákavý",
}
@dataclasses.dataclass(frozen=True)
class Language:
name: str # in the language itself
decimal_point: str = "."
texts: dict[str, str] = dataclasses.field(default_factory=dict) # English text: its translation
species: dict[str, str] = dataclasses.field(default_factory=dict) # SPECIES key: its name
# Keyed by ISO 639-1 code, the way locale names start. English needs no catalogue:
# its texts are the keys, and the SPECIES keys its species names.
LANGUAGES = {
"cs": Language("Čeština", ",", CZECH, CZECH_SPECIES),
"en": Language("English"),
}
def N_(text: str) -> str:
"""Mark a text as one to translate where it is shown, as gettext's N_ does; it is returned as it is."""
return text
def translate(text: str, language: str) -> str:
return LANGUAGES[language].texts.get(text, text)
def species_name(species: str, language: str) -> str:
return LANGUAGES[language].species.get(species, species)
def number(value: float, spec: str, language: str) -> str:
"""format(value, spec), with the language's decimal point."""
return format(value, spec).replace(".", LANGUAGES[language].decimal_point)
def _language_of(locale_name: str) -> str | None:
""""en" from "en_GB.UTF-8", if it is one of LANGUAGES."""
code = locale_name.lower().split("_")[0].split(".")[0].split("@")[0]
return code if code in LANGUAGES else None
def system_language() -> str:
"""The first of LANGUAGES the user's system asks for, and English if none.
Like gettext, only the first of LANGUAGE, LC_ALL, LC_MESSAGES and LANG that is set
counts, and LANGUAGE may list several languages. Windows usually sets none of them,
so there the user's interface language is asked for instead.
"""
for variable in ("LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG"):
value = os.environ.get(variable)
if value:
for name in value.split(":"):
language = _language_of(name)
if language:
return language
return "en"
if sys.platform == "win32":
import ctypes
name = locale.windows_locale.get(ctypes.windll.kernel32.GetUserDefaultUILanguage(), "")
else:
name = locale.getlocale()[0] or ""
return _language_of(name) or "en"