ravnpad 1.2.6

A simple UTF-8 notepad
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
use crate::large::FileError;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Lang {
    English,
    Bokmal,
    Nynorsk,
    Swedish,
    Danish,
    German,
    Dutch,
    French,
    Spanish,
    Italian,
    Portuguese,
    Finnish,
    Polish,
    Icelandic,
    Czech,
}

impl Lang {
    pub const ALL: &[Self] = &[
        Self::Bokmal,
        Self::Nynorsk,
        Self::English,
        Self::Swedish,
        Self::Danish,
        Self::Icelandic,
        Self::German,
        Self::Dutch,
        Self::French,
        Self::Spanish,
        Self::Italian,
        Self::Portuguese,
        Self::Finnish,
        Self::Polish,
        Self::Czech,
    ];

    pub fn code(self) -> &'static str {
        match self {
            Self::English => "en",
            Self::Bokmal => "nb",
            Self::Nynorsk => "nn",
            Self::Swedish => "sv",
            Self::Danish => "da",
            Self::German => "de",
            Self::Dutch => "nl",
            Self::French => "fr",
            Self::Spanish => "es",
            Self::Italian => "it",
            Self::Portuguese => "pt",
            Self::Finnish => "fi",
            Self::Polish => "pl",
            Self::Icelandic => "is",
            Self::Czech => "cs",
        }
    }

    pub fn native_name(self) -> &'static str {
        match self {
            Self::English => "English",
            Self::Bokmal => "Norsk bokmål",
            Self::Nynorsk => "Norsk nynorsk",
            Self::Swedish => "Svenska",
            Self::Danish => "Dansk",
            Self::German => "Deutsch",
            Self::Dutch => "Nederlands",
            Self::French => "Français",
            Self::Spanish => "Español",
            Self::Italian => "Italiano",
            Self::Portuguese => "Português",
            Self::Finnish => "Suomi",
            Self::Polish => "Polski",
            Self::Icelandic => "Íslenska",
            Self::Czech => "Čeština",
        }
    }

    pub fn from_code(code: &str) -> Option<Self> {
        match code.trim().to_ascii_lowercase().as_str() {
            "en" => Some(Self::English),
            "nb" | "no" => Some(Self::Bokmal),
            "nn" => Some(Self::Nynorsk),
            "sv" => Some(Self::Swedish),
            "da" => Some(Self::Danish),
            "de" => Some(Self::German),
            "nl" => Some(Self::Dutch),
            "fr" => Some(Self::French),
            "es" => Some(Self::Spanish),
            "it" => Some(Self::Italian),
            "pt" => Some(Self::Portuguese),
            "fi" => Some(Self::Finnish),
            "pl" => Some(Self::Polish),
            "is" => Some(Self::Icelandic),
            "cs" => Some(Self::Czech),
            _ => None,
        }
    }

    pub fn from_locale(locale: &str) -> Option<Self> {
        let primary = locale
            .split(['.', '@'])
            .next()
            .unwrap_or(locale)
            .replace('_', "-");
        let lang = primary.split('-').next().unwrap_or(&primary);
        Self::from_code(lang)
    }

    pub fn text(self) -> &'static UiText {
        match self {
            Self::English => &EN,
            Self::Bokmal => &NB,
            Self::Nynorsk => &NN,
            Self::Swedish => &SV,
            Self::Danish => &DA,
            Self::German => &DE,
            Self::Dutch => &NL,
            Self::French => &FR,
            Self::Spanish => &ES,
            Self::Italian => &IT,
            Self::Portuguese => &PT,
            Self::Finnish => &FI,
            Self::Polish => &PL,
            Self::Icelandic => &IS,
            Self::Czech => &CS,
        }
    }
}

pub struct UiText {
    pub file_menu: &'static str,
    pub language_menu: &'static str,
    pub settings_menu: &'static str,
    pub font_label: &'static str,
    pub font_size_label: &'static str,
    pub font_default: &'static str,
    pub new: &'static str,
    pub open: &'static str,
    pub save: &'static str,
    pub save_as: &'static str,
    pub quit: &'static str,
    pub help_menu: &'static str,
    pub update_menu: &'static str,
    pub untitled: &'static str,
    pub untitled_file: &'static str,
    pub chars_unit: &'static str,
    pub unsaved_title: &'static str,
    pub unsaved_body: &'static str,
    pub dont_save: &'static str,
    pub cancel: &'static str,
    pub error_title: &'static str,
    pub ok: &'static str,
    pub drop_to_open: &'static str,
    pub view_readonly: &'static str,
    pub cannot_open: &'static str,
    pub cannot_save: &'static str,
    pub cannot_read: &'static str,
    pub invalid_utf8: &'static str,
    pub invalid_rtf: &'static str,
    pub too_large_edit: &'static str,
    pub drop_too_large: &'static str,
    pub update_available_title: &'static str,
    pub update_available_body: &'static str,
    pub update_now: &'static str,
    pub update_later: &'static str,
    pub update_checking: &'static str,
    pub update_downloading: &'static str,
    pub update_uptodate: &'static str,
    pub update_failed: &'static str,
    pub update_unsupported: &'static str,
    pub decimal: char,
}

impl UiText {
    pub fn chars(&self, n: usize) -> String {
        format!("{} {}", n, self.chars_unit)
    }

    pub fn unsaved(&self, name: &str) -> String {
        self.unsaved_body.replace("{}", name)
    }

    pub fn file_error(&self, err: &FileError) -> String {
        match err {
            FileError::Open(err) => format!("{}:\n{err}", self.cannot_open),
            FileError::Read(err) => format!("{}:\n{err}", self.cannot_read),
            FileError::InvalidUtf8 => self.invalid_utf8.to_owned(),
            FileError::InvalidRtf => self.invalid_rtf.to_owned(),
        }
    }

    pub fn save_error(&self, err: &std::io::Error) -> String {
        format!("{}:\n{err}", self.cannot_save)
    }

    pub fn update_available(&self, new: &str, current: &str) -> String {
        self.update_available_body
            .replace("{new}", new)
            .replace("{current}", current)
    }

    pub fn update_uptodate_msg(&self, version: &str) -> String {
        self.update_uptodate.replace("{version}", version)
    }
}

pub fn detect() -> Lang {
    Lang::from_locale(&system_locale().unwrap_or_default()).unwrap_or(Lang::English)
}

fn system_locale() -> Option<String> {
    #[cfg(windows)]
    {
        use winreg::enums::HKEY_CURRENT_USER;
        use winreg::RegKey;
        RegKey::predef(HKEY_CURRENT_USER)
            .open_subkey("Control Panel\\International")
            .ok()?
            .get_value("LocaleName")
            .ok()
    }
    #[cfg(not(windows))]
    {
        std::env::var("LC_ALL")
            .or_else(|_| std::env::var("LC_MESSAGES"))
            .or_else(|_| std::env::var("LANG"))
            .ok()
    }
}

const EN: UiText = UiText {
    file_menu: "File",
    language_menu: "Language",
    settings_menu: "Settings",
    font_label: "Font",
    font_size_label: "Size",
    font_default: "Default",
    new: "New",
    open: "Open…",
    save: "Save",
    save_as: "Save as…",
    quit: "Quit",
    help_menu: "Help",
    update_menu: "Check for updates…",
    untitled: "Untitled",
    untitled_file: "untitled.txt",
    chars_unit: "characters",
    unsaved_title: "Unsaved changes",
    unsaved_body: "“{}” has unsaved changes. Save before continuing?",
    dont_save: "Don't save",
    cancel: "Cancel",
    error_title: "Error",
    ok: "OK",
    drop_to_open: "Drop to open",
    view_readonly: "view (read-only)",
    cannot_open: "Could not open the file",
    cannot_save: "Could not save the file",
    cannot_read: "Could not read the file",
    invalid_utf8: "The file is not valid UTF-8 text.",
    invalid_rtf: "Could not convert the RTF file to text.",
    too_large_edit: "The file is too large to edit in RavnPad. This view is read-only.",
    drop_too_large: "The file is too large to open via drag-and-drop. Open it from disk instead.",
    update_available_title: "Update available",
    update_available_body: "RavnPad {new} is available. You have {current}.",
    update_now: "Update",
    update_later: "Later",
    update_checking: "Checking for updates…",
    update_downloading: "Downloading update…",
    update_uptodate: "RavnPad is up to date ({version}).",
    update_failed: "Could not update RavnPad.",
    update_unsupported: "Automatic updates are not available on this system.",
    decimal: '.',
};

const NB: UiText = UiText {
    file_menu: "Fil",
    language_menu: "Språk",
    settings_menu: "Innstillinger",
    font_label: "Skrift",
    font_size_label: "Størrelse",
    font_default: "Standard",
    new: "Ny",
    open: "Åpne…",
    save: "Lagre",
    save_as: "Lagre som…",
    quit: "Avslutt",
    help_menu: "Hjelp",
    update_menu: "Se etter oppdateringer…",
    untitled: "Uten tittel",
    untitled_file: "uten-tittel.txt",
    chars_unit: "tegn",
    unsaved_title: "Ulagrede endringer",
    unsaved_body: "«{}» har ulagrede endringer. Vil du lagre før du fortsetter?",
    dont_save: "Ikke lagre",
    cancel: "Avbryt",
    error_title: "Feil",
    ok: "OK",
    drop_to_open: "Slipp for å åpne",
    view_readonly: "visning (skrivebeskyttet)",
    cannot_open: "Kunne ikke åpne filen",
    cannot_save: "Kunne ikke lagre filen",
    cannot_read: "Kunne ikke lese filen",
    invalid_utf8: "Filen er ikke gyldig UTF-8-tekst.",
    invalid_rtf: "Kunne ikke konvertere RTF-filen til tekst.",
    too_large_edit: "Filen er for stor til å redigeres i RavnPad. Visningen er skrivebeskyttet.",
    drop_too_large: "Filen er for stor til å åpnes via dra-og-slipp. Åpne den fra disk i stedet.",
    update_available_title: "Oppdatering tilgjengelig",
    update_available_body: "RavnPad {new} er tilgjengelig. Du har {current}.",
    update_now: "Oppdater",
    update_later: "Senere",
    update_checking: "Ser etter oppdateringer…",
    update_downloading: "Laster ned oppdatering…",
    update_uptodate: "RavnPad er oppdatert ({version}).",
    update_failed: "Kunne ikke oppdatere RavnPad.",
    update_unsupported: "Automatiske oppdateringer er ikke tilgjengelig på dette systemet.",
    decimal: ',',
};

const NN: UiText = UiText {
    file_menu: "Fil",
    language_menu: "Språk",
    settings_menu: "Innstillingar",
    font_label: "Skrift",
    font_size_label: "Storleik",
    font_default: "Standard",
    new: "Ny",
    open: "Opne…",
    save: "Lagre",
    save_as: "Lagre som…",
    quit: "Avslutt",
    help_menu: "Hjelp",
    update_menu: "Sjå etter oppdateringar…",
    untitled: "Utan tittel",
    untitled_file: "utan-tittel.txt",
    chars_unit: "teikn",
    unsaved_title: "Ulagra endringar",
    unsaved_body: "«{}» har ulagra endringar. Vil du lagre før du held fram?",
    dont_save: "Ikkje lagre",
    cancel: "Avbryt",
    error_title: "Feil",
    ok: "OK",
    drop_to_open: "Slepp for å opne",
    view_readonly: "vising (skriveverna)",
    cannot_open: "Kunne ikkje opne fila",
    cannot_save: "Kunne ikkje lagre fila",
    cannot_read: "Kunne ikkje lese fila",
    invalid_utf8: "Fila er ikkje gyldig UTF-8-tekst.",
    invalid_rtf: "Kunne ikkje konvertere RTF-fila til tekst.",
    too_large_edit: "Fila er for stor til å redigerast i RavnPad. Visinga er skriveverna.",
    drop_too_large: "Fila er for stor til å opnast via dra-og-slep. Opne ho frå disk i staden.",
    update_available_title: "Oppdatering tilgjengeleg",
    update_available_body: "RavnPad {new} er tilgjengeleg. Du har {current}.",
    update_now: "Oppdater",
    update_later: "Seinare",
    update_checking: "Ser etter oppdateringar…",
    update_downloading: "Lastar ned oppdatering…",
    update_uptodate: "RavnPad er oppdatert ({version}).",
    update_failed: "Kunne ikkje oppdatere RavnPad.",
    update_unsupported: "Automatiske oppdateringar er ikkje tilgjengelege på dette systemet.",
    decimal: ',',
};

const SV: UiText = UiText {
    file_menu: "Arkiv",
    language_menu: "Språk",
    settings_menu: "Inställningar",
    font_label: "Typsnitt",
    font_size_label: "Storlek",
    font_default: "Standard",
    new: "Ny",
    open: "Öppna…",
    save: "Spara",
    save_as: "Spara som…",
    quit: "Avsluta",
    help_menu: "Hjälp",
    update_menu: "Sök efter uppdateringar…",
    untitled: "Namnlös",
    untitled_file: "namnlos.txt",
    chars_unit: "tecken",
    unsaved_title: "Osparade ändringar",
    unsaved_body: "“{}” har osparade ändringar. Vill du spara innan du fortsätter?",
    dont_save: "Spara inte",
    cancel: "Avbryt",
    error_title: "Fel",
    ok: "OK",
    drop_to_open: "Släpp för att öppna",
    view_readonly: "visning (skrivskyddad)",
    cannot_open: "Kunde inte öppna filen",
    cannot_save: "Kunde inte spara filen",
    cannot_read: "Kunde inte läsa filen",
    invalid_utf8: "Filen är inte giltig UTF-8-text.",
    invalid_rtf: "Kunde inte konvertera RTF-filen till text.",
    too_large_edit: "Filen är för stor för att redigeras i RavnPad. Visningen är skrivskyddad.",
    drop_too_large: "Filen är för stor för att öppnas via dra-och-släpp. Öppna den från disken i stället.",
    update_available_title: "Uppdatering tillgänglig",
    update_available_body: "RavnPad {new} finns tillgänglig. Du har {current}.",
    update_now: "Uppdatera",
    update_later: "Senare",
    update_checking: "Söker efter uppdateringar…",
    update_downloading: "Laddar ner uppdatering…",
    update_uptodate: "RavnPad är uppdaterad ({version}).",
    update_failed: "Kunde inte uppdatera RavnPad.",
    update_unsupported: "Automatiska uppdateringar är inte tillgängliga på det här systemet.",
    decimal: ',',
};

const DA: UiText = UiText {
    file_menu: "Filer",
    language_menu: "Sprog",
    settings_menu: "Indstillinger",
    font_label: "Skrifttype",
    font_size_label: "Størrelse",
    font_default: "Standard",
    new: "Ny",
    open: "Åbn…",
    save: "Gem",
    save_as: "Gem som…",
    quit: "Afslut",
    help_menu: "Hjælp",
    update_menu: "Søg efter opdateringer…",
    untitled: "Unavngivet",
    untitled_file: "unavngivet.txt",
    chars_unit: "tegn",
    unsaved_title: "Ikke-gemte ændringer",
    unsaved_body: "«{}» har ændringer, der ikke er gemt. Vil du gemme, før du fortsætter?",
    dont_save: "Gem ikke",
    cancel: "Annuller",
    error_title: "Fejl",
    ok: "OK",
    drop_to_open: "Slip for at åbne",
    view_readonly: "visning (skrivebeskyttet)",
    cannot_open: "Kunne ikke åbne filen",
    cannot_save: "Kunne ikke gemme filen",
    cannot_read: "Kunne ikke læse filen",
    invalid_utf8: "Filen er ikke gyldig UTF-8-tekst.",
    invalid_rtf: "Kunne ikke konvertere RTF-filen til tekst.",
    too_large_edit: "Filen er for stor til at redigeres i RavnPad. Visningen er skrivebeskyttet.",
    drop_too_large: "Filen er for stor til at åbnes via træk-og-slip. Åbn den fra disken i stedet.",
    update_available_title: "Opdatering tilgængelig",
    update_available_body: "RavnPad {new} er tilgængelig. Du har {current}.",
    update_now: "Opdater",
    update_later: "Senere",
    update_checking: "Søger efter opdateringer…",
    update_downloading: "Henter opdatering…",
    update_uptodate: "RavnPad er opdateret ({version}).",
    update_failed: "Kunne ikke opdatere RavnPad.",
    update_unsupported: "Automatiske opdateringer er ikke tilgængelige på dette system.",
    decimal: ',',
};

const DE: UiText = UiText {
    file_menu: "Datei",
    language_menu: "Sprache",
    settings_menu: "Einstellungen",
    font_label: "Schriftart",
    font_size_label: "Größe",
    font_default: "Standard",
    new: "Neu",
    open: "Öffnen…",
    save: "Speichern",
    save_as: "Speichern unter…",
    quit: "Beenden",
    help_menu: "Hilfe",
    update_menu: "Nach Updates suchen…",
    untitled: "Unbenannt",
    untitled_file: "unbenannt.txt",
    chars_unit: "Zeichen",
    unsaved_title: "Ungespeicherte Änderungen",
    unsaved_body: "„{}“ enthält ungespeicherte Änderungen. Speichern, bevor Sie fortfahren?",
    dont_save: "Nicht speichern",
    cancel: "Abbrechen",
    error_title: "Fehler",
    ok: "OK",
    drop_to_open: "Zum Öffnen ablegen",
    view_readonly: "Ansicht (schreibgeschützt)",
    cannot_open: "Datei konnte nicht geöffnet werden",
    cannot_save: "Datei konnte nicht gespeichert werden",
    cannot_read: "Datei konnte nicht gelesen werden",
    invalid_utf8: "Die Datei ist kein gültiger UTF-8-Text.",
    invalid_rtf: "Die RTF-Datei konnte nicht in Text umgewandelt werden.",
    too_large_edit: "Die Datei ist zu groß zum Bearbeiten in RavnPad. Die Ansicht ist schreibgeschützt.",
    drop_too_large: "Die Datei ist zu groß zum Öffnen per Drag-and-drop. Öffnen Sie sie von der Festplatte.",
    update_available_title: "Update verfügbar",
    update_available_body: "RavnPad {new} ist verfügbar. Sie haben {current}.",
    update_now: "Aktualisieren",
    update_later: "Später",
    update_checking: "Suche nach Updates…",
    update_downloading: "Update wird heruntergeladen…",
    update_uptodate: "RavnPad ist aktuell ({version}).",
    update_failed: "RavnPad konnte nicht aktualisiert werden.",
    update_unsupported: "Automatische Updates sind auf diesem System nicht verfügbar.",
    decimal: ',',
};

const NL: UiText = UiText {
    file_menu: "Bestand",
    language_menu: "Taal",
    settings_menu: "Instellingen",
    font_label: "Lettertype",
    font_size_label: "Grootte",
    font_default: "Standaard",
    new: "Nieuw",
    open: "Openen…",
    save: "Opslaan",
    save_as: "Opslaan als…",
    quit: "Afsluiten",
    help_menu: "Help",
    update_menu: "Controleren op updates…",
    untitled: "Naamloos",
    untitled_file: "naamloos.txt",
    chars_unit: "tekens",
    unsaved_title: "Niet-opgeslagen wijzigingen",
    unsaved_body: "“{}” heeft niet-opgeslagen wijzigingen. Opslaan voordat u doorgaat?",
    dont_save: "Niet opslaan",
    cancel: "Annuleren",
    error_title: "Fout",
    ok: "OK",
    drop_to_open: "Sleep om te openen",
    view_readonly: "weergave (alleen-lezen)",
    cannot_open: "Kan het bestand niet openen",
    cannot_save: "Kan het bestand niet opslaan",
    cannot_read: "Kan het bestand niet lezen",
    invalid_utf8: "Het bestand is geen geldige UTF-8-tekst.",
    invalid_rtf: "Het RTF-bestand kon niet naar tekst worden omgezet.",
    too_large_edit: "Het bestand is te groot om in RavnPad te bewerken. Deze weergave is alleen-lezen.",
    drop_too_large: "Het bestand is te groot om via slepen-en-neerzetten te openen. Open het vanaf de schijf.",
    update_available_title: "Update beschikbaar",
    update_available_body: "RavnPad {new} is beschikbaar. U hebt {current}.",
    update_now: "Bijwerken",
    update_later: "Later",
    update_checking: "Controleren op updates…",
    update_downloading: "Update downloaden…",
    update_uptodate: "RavnPad is up-to-date ({version}).",
    update_failed: "RavnPad kon niet worden bijgewerkt.",
    update_unsupported: "Automatische updates zijn niet beschikbaar op dit systeem.",
    decimal: ',',
};

const FR: UiText = UiText {
    file_menu: "Fichier",
    language_menu: "Langue",
    settings_menu: "Paramètres",
    font_label: "Police",
    font_size_label: "Taille",
    font_default: "Par défaut",
    new: "Nouveau",
    open: "Ouvrir…",
    save: "Enregistrer",
    save_as: "Enregistrer sous…",
    quit: "Quitter",
    help_menu: "Aide",
    update_menu: "Rechercher des mises à jour…",
    untitled: "Sans titre",
    untitled_file: "sans-titre.txt",
    chars_unit: "caractères",
    unsaved_title: "Modifications non enregistrées",
    unsaved_body: "« {} » contient des modifications non enregistrées. Enregistrer avant de continuer ?",
    dont_save: "Ne pas enregistrer",
    cancel: "Annuler",
    error_title: "Erreur",
    ok: "OK",
    drop_to_open: "Déposer pour ouvrir",
    view_readonly: "affichage (lecture seule)",
    cannot_open: "Impossible d’ouvrir le fichier",
    cannot_save: "Impossible d’enregistrer le fichier",
    cannot_read: "Impossible de lire le fichier",
    invalid_utf8: "Le fichier n’est pas un texte UTF-8 valide.",
    invalid_rtf: "Impossible de convertir le fichier RTF en texte.",
    too_large_edit: "Le fichier est trop volumineux pour être modifié dans RavnPad. Cet affichage est en lecture seule.",
    drop_too_large: "Le fichier est trop volumineux pour être ouvert par glisser-déposer. Ouvrez-le depuis le disque.",
    update_available_title: "Mise à jour disponible",
    update_available_body: "RavnPad {new} est disponible. Vous avez {current}.",
    update_now: "Mettre à jour",
    update_later: "Plus tard",
    update_checking: "Recherche de mises à jour…",
    update_downloading: "Téléchargement de la mise à jour…",
    update_uptodate: "RavnPad est à jour ({version}).",
    update_failed: "Impossible de mettre à jour RavnPad.",
    update_unsupported: "Les mises à jour automatiques ne sont pas disponibles sur ce système.",
    decimal: ',',
};

const ES: UiText = UiText {
    file_menu: "Archivo",
    language_menu: "Idioma",
    settings_menu: "Ajustes",
    font_label: "Fuente",
    font_size_label: "Tamaño",
    font_default: "Predeterminada",
    new: "Nuevo",
    open: "Abrir…",
    save: "Guardar",
    save_as: "Guardar como…",
    quit: "Salir",
    help_menu: "Ayuda",
    update_menu: "Buscar actualizaciones…",
    untitled: "Sin título",
    untitled_file: "sin-titulo.txt",
    chars_unit: "caracteres",
    unsaved_title: "Cambios sin guardar",
    unsaved_body: "«{}» tiene cambios sin guardar. ¿Guardar antes de continuar?",
    dont_save: "No guardar",
    cancel: "Cancelar",
    error_title: "Error",
    ok: "Aceptar",
    drop_to_open: "Suelte para abrir",
    view_readonly: "vista (solo lectura)",
    cannot_open: "No se pudo abrir el archivo",
    cannot_save: "No se pudo guardar el archivo",
    cannot_read: "No se pudo leer el archivo",
    invalid_utf8: "El archivo no es texto UTF-8 válido.",
    invalid_rtf: "No se pudo convertir el archivo RTF a texto.",
    too_large_edit: "El archivo es demasiado grande para editarlo en RavnPad. Esta vista es de solo lectura.",
    drop_too_large: "El archivo es demasiado grande para abrirlo arrastrándolo. Ábralo desde el disco.",
    update_available_title: "Actualización disponible",
    update_available_body: "RavnPad {new} está disponible. Tienes {current}.",
    update_now: "Actualizar",
    update_later: "Más tarde",
    update_checking: "Buscando actualizaciones…",
    update_downloading: "Descargando actualización…",
    update_uptodate: "RavnPad está actualizado ({version}).",
    update_failed: "No se pudo actualizar RavnPad.",
    update_unsupported: "Las actualizaciones automáticas no están disponibles en este sistema.",
    decimal: ',',
};

const IT: UiText = UiText {
    file_menu: "File",
    language_menu: "Lingua",
    settings_menu: "Impostazioni",
    font_label: "Carattere",
    font_size_label: "Dimensione",
    font_default: "Predefinito",
    new: "Nuovo",
    open: "Apri…",
    save: "Salva",
    save_as: "Salva con nome…",
    quit: "Esci",
    help_menu: "Aiuto",
    update_menu: "Verifica aggiornamenti…",
    untitled: "Senza titolo",
    untitled_file: "senza-titolo.txt",
    chars_unit: "caratteri",
    unsaved_title: "Modifiche non salvate",
    unsaved_body: "«{}» contiene modifiche non salvate. Salvare prima di continuare?",
    dont_save: "Non salvare",
    cancel: "Annulla",
    error_title: "Errore",
    ok: "OK",
    drop_to_open: "Rilascia per aprire",
    view_readonly: "visualizzazione (sola lettura)",
    cannot_open: "Impossibile aprire il file",
    cannot_save: "Impossibile salvare il file",
    cannot_read: "Impossibile leggere il file",
    invalid_utf8: "Il file non è testo UTF-8 valido.",
    invalid_rtf: "Impossibile convertire il file RTF in testo.",
    too_large_edit: "Il file è troppo grande per essere modificato in RavnPad. Questa vista è in sola lettura.",
    drop_too_large: "Il file è troppo grande per l’apertura tramite trascinamento. Aprilo dal disco.",
    update_available_title: "Aggiornamento disponibile",
    update_available_body: "RavnPad {new} è disponibile. Hai {current}.",
    update_now: "Aggiorna",
    update_later: "Più tardi",
    update_checking: "Verifica aggiornamenti…",
    update_downloading: "Download dell’aggiornamento…",
    update_uptodate: "RavnPad è aggiornato ({version}).",
    update_failed: "Impossibile aggiornare RavnPad.",
    update_unsupported: "Gli aggiornamenti automatici non sono disponibili su questo sistema.",
    decimal: ',',
};

const PT: UiText = UiText {
    file_menu: "Ficheiro",
    language_menu: "Idioma",
    settings_menu: "Definições",
    font_label: "Tipo de letra",
    font_size_label: "Tamanho",
    font_default: "Predefinido",
    new: "Novo",
    open: "Abrir…",
    save: "Guardar",
    save_as: "Guardar como…",
    quit: "Sair",
    help_menu: "Ajuda",
    update_menu: "Procurar atualizações…",
    untitled: "Sem título",
    untitled_file: "sem-titulo.txt",
    chars_unit: "caracteres",
    unsaved_title: "Alterações não guardadas",
    unsaved_body: "«{}» tem alterações não guardadas. Guardar antes de continuar?",
    dont_save: "Não guardar",
    cancel: "Cancelar",
    error_title: "Erro",
    ok: "OK",
    drop_to_open: "Largue para abrir",
    view_readonly: "visualização (só de leitura)",
    cannot_open: "Não foi possível abrir o ficheiro",
    cannot_save: "Não foi possível guardar o ficheiro",
    cannot_read: "Não foi possível ler o ficheiro",
    invalid_utf8: "O ficheiro não é texto UTF-8 válido.",
    invalid_rtf: "Não foi possível converter o ficheiro RTF em texto.",
    too_large_edit: "O ficheiro é demasiado grande para ser editado no RavnPad. Esta vista é só de leitura.",
    drop_too_large: "O ficheiro é demasiado grande para abrir por arrastar. Abra-o a partir do disco.",
    update_available_title: "Atualização disponível",
    update_available_body: "RavnPad {new} está disponível. Você tem {current}.",
    update_now: "Atualizar",
    update_later: "Mais tarde",
    update_checking: "A procurar atualizações…",
    update_downloading: "A descarregar atualização…",
    update_uptodate: "RavnPad está atualizado ({version}).",
    update_failed: "Não foi possível atualizar o RavnPad.",
    update_unsupported: "As atualizações automáticas não estão disponíveis neste sistema.",
    decimal: ',',
};

const FI: UiText = UiText {
    file_menu: "Tiedosto",
    language_menu: "Kieli",
    settings_menu: "Asetukset",
    font_label: "Fontti",
    font_size_label: "Koko",
    font_default: "Oletus",
    new: "Uusi",
    open: "Avaa…",
    save: "Tallenna",
    save_as: "Tallenna nimellä…",
    quit: "Lopeta",
    help_menu: "Ohje",
    update_menu: "Tarkista päivitykset…",
    untitled: "Nimetön",
    untitled_file: "nimetön.txt",
    chars_unit: "merkkiä",
    unsaved_title: "Tallentamattomia muutoksia",
    unsaved_body: "Tiedostossa «{}» on tallentamattomia muutoksia. Tallennetaanko ennen jatkamista?",
    dont_save: "Älä tallenna",
    cancel: "Peruuta",
    error_title: "Virhe",
    ok: "OK",
    drop_to_open: "Avaa pudottamalla",
    view_readonly: "näkymä (vain luku)",
    cannot_open: "Tiedostoa ei voitu avata",
    cannot_save: "Tiedostoa ei voitu tallentaa",
    cannot_read: "Tiedostoa ei voitu lukea",
    invalid_utf8: "Tiedosto ei ole kelvollista UTF-8-tekstiä.",
    invalid_rtf: "RTF-tiedostoa ei voitu muuntaa tekstiksi.",
    too_large_edit: "Tiedosto on liian suuri muokattavaksi RavnPadissa. Näkymä on vain luku.",
    drop_too_large: "Tiedosto on liian suuri avattavaksi raahaamalla. Avaa se levyltä.",
    update_available_title: "Päivitys saatavilla",
    update_available_body: "RavnPad {new} on saatavilla. Nykyinen versio on {current}.",
    update_now: "Päivitä",
    update_later: "Myöhemmin",
    update_checking: "Tarkistetaan päivityksiä…",
    update_downloading: "Ladataan päivitystä…",
    update_uptodate: "RavnPad on ajan tasalla ({version}).",
    update_failed: "RavnPadia ei voitu päivittää.",
    update_unsupported: "Automaattiset päivitykset eivät ole käytettävissä tällä järjestelmällä.",
    decimal: ',',
};

const PL: UiText = UiText {
    file_menu: "Plik",
    language_menu: "Język",
    settings_menu: "Ustawienia",
    font_label: "Czcionka",
    font_size_label: "Rozmiar",
    font_default: "Domyślna",
    new: "Nowy",
    open: "Otwórz…",
    save: "Zapisz",
    save_as: "Zapisz jako…",
    quit: "Zakończ",
    help_menu: "Pomoc",
    update_menu: "Sprawdź aktualizacje…",
    untitled: "Bez tytułu",
    untitled_file: "bez-tytulu.txt",
    chars_unit: "znaków",
    unsaved_title: "Niezapisane zmiany",
    unsaved_body: "«{}» ma niezapisane zmiany. Zapisać przed kontynuowaniem?",
    dont_save: "Nie zapisuj",
    cancel: "Anuluj",
    error_title: "Błąd",
    ok: "OK",
    drop_to_open: "Upuść, aby otworzyć",
    view_readonly: "widok (tylko do odczytu)",
    cannot_open: "Nie można otworzyć pliku",
    cannot_save: "Nie można zapisać pliku",
    cannot_read: "Nie można odczytać pliku",
    invalid_utf8: "Plik nie jest poprawnym tekstem UTF-8.",
    invalid_rtf: "Nie można przekonwertować pliku RTF na tekst.",
    too_large_edit: "Plik jest za duży, aby edytować go w RavnPad. Ten widok jest tylko do odczytu.",
    drop_too_large: "Plik jest za duży, aby otworzyć go metodą przeciągnij i upuść. Otwórz go z dysku.",
    update_available_title: "Dostępna aktualizacja",
    update_available_body: "RavnPad {new} jest dostępny. Masz {current}.",
    update_now: "Aktualizuj",
    update_later: "Później",
    update_checking: "Sprawdzanie aktualizacji…",
    update_downloading: "Pobieranie aktualizacji…",
    update_uptodate: "RavnPad jest aktualny ({version}).",
    update_failed: "Nie można zaktualizować RavnPad.",
    update_unsupported: "Automatyczne aktualizacje nie są dostępne w tym systemie.",
    decimal: ',',
};

const IS: UiText = UiText {
    file_menu: "Skrá",
    language_menu: "Tungumál",
    settings_menu: "Stillingar",
    font_label: "Letur",
    font_size_label: "Stærð",
    font_default: "Sjálfgefið",
    new: "Nýtt",
    open: "Opna…",
    save: "Vista",
    save_as: "Vista sem…",
    quit: "Hætta",
    help_menu: "Hjálp",
    update_menu: "Leita að uppfærslum…",
    untitled: "Ónefnt",
    untitled_file: "onefnt.txt",
    chars_unit: "stafir",
    unsaved_title: "Óvistaðar breytingar",
    unsaved_body: "„{}“ hefur óvistaðar breytingar. Vista áður en haldið er áfram?",
    dont_save: "Ekki vista",
    cancel: "Hætta við",
    error_title: "Villa",
    ok: "Í lagi",
    drop_to_open: "Slepptu til að opna",
    view_readonly: "sýn (skrifvarið)",
    cannot_open: "Gat ekki opnað skrána",
    cannot_save: "Gat ekki vistað skrána",
    cannot_read: "Gat ekki lesið skrána",
    invalid_utf8: "Skráin er ekki gildur UTF-8-texti.",
    invalid_rtf: "Gat ekki umbreytt RTF-skránni í texta.",
    too_large_edit: "Skráin er of stór til að breyta í RavnPad. Þessi sýn er skrifvarin.",
    drop_too_large: "Skráin er of stór til að opna með dragi og sleppi. Opnaðu hana af diski.",
    update_available_title: "Uppfærsla í boði",
    update_available_body: "RavnPad {new} er í boði. Þú ert með {current}.",
    update_now: "Uppfæra",
    update_later: "Seinna",
    update_checking: "Leita að uppfærslum…",
    update_downloading: "Sæki uppfærslu…",
    update_uptodate: "RavnPad er uppfært ({version}).",
    update_failed: "Gat ekki uppfært RavnPad.",
    update_unsupported: "Sjálfvirkar uppfærslur eru ekki í boði á þessu kerfi.",
    decimal: ',',
};

const CS: UiText = UiText {
    file_menu: "Soubor",
    language_menu: "Jazyk",
    settings_menu: "Nastavení",
    font_label: "Písmo",
    font_size_label: "Velikost",
    font_default: "Výchozí",
    new: "Nový",
    open: "Otevřít…",
    save: "Uložit",
    save_as: "Uložit jako…",
    quit: "Konec",
    help_menu: "Nápověda",
    update_menu: "Zkontrolovat aktualizace…",
    untitled: "Bez názvu",
    untitled_file: "bez-nazvu.txt",
    chars_unit: "znaků",
    unsaved_title: "Neuložené změny",
    unsaved_body: "«{}» obsahuje neuložené změny. Uložit před pokračováním?",
    dont_save: "Neukládat",
    cancel: "Zrušit",
    error_title: "Chyba",
    ok: "OK",
    drop_to_open: "Přetáhněte pro otevření",
    view_readonly: "zobrazení (jen ke čtení)",
    cannot_open: "Soubor se nepodařilo otevřít",
    cannot_save: "Soubor se nepodařilo uložit",
    cannot_read: "Soubor se nepodařilo přečíst",
    invalid_utf8: "Soubor není platný text UTF-8.",
    invalid_rtf: "Soubor RTF se nepodařilo převést na text.",
    too_large_edit: "Soubor je příliš velký na úpravy v RavnPad. Toto zobrazení je jen ke čtení.",
    drop_too_large: "Soubor je příliš velký na otevření přetažením. Otevřete jej z disku.",
    update_available_title: "Je k dispozici aktualizace",
    update_available_body: "RavnPad {new} je k dispozici. Máte {current}.",
    update_now: "Aktualizovat",
    update_later: "Později",
    update_checking: "Kontrola aktualizací…",
    update_downloading: "Stahování aktualizace…",
    update_uptodate: "RavnPad je aktuální ({version}).",
    update_failed: "RavnPad se nepodařilo aktualizovat.",
    update_unsupported: "Automatické aktualizace nejsou v tomto systému k dispozici.",
    decimal: ',',
};

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn locale_nb_and_no_map_to_bokmal() {
        assert_eq!(Lang::from_locale("nb_NO.UTF-8"), Some(Lang::Bokmal));
        assert_eq!(Lang::from_locale("nb-NO"), Some(Lang::Bokmal));
        assert_eq!(Lang::from_locale("no"), Some(Lang::Bokmal));
    }

    #[test]
    fn locale_nn_maps_to_nynorsk() {
        assert_eq!(Lang::from_locale("nn_NO.UTF-8"), Some(Lang::Nynorsk));
    }

    #[test]
    fn unknown_locale_is_none() {
        assert_eq!(Lang::from_locale("ja_JP"), None);
        assert_eq!(Lang::from_code("xx"), None);
    }

    #[test]
    fn every_language_has_unique_code() {
        let mut codes: Vec<_> = Lang::ALL.iter().map(|lang| lang.code()).collect();
        codes.sort_unstable();
        codes.dedup();
        assert_eq!(codes.len(), Lang::ALL.len());
    }
}