iced_code_editor/i18n.rs
1//! Internationalization support for the code editor.
2//!
3//! This module provides translation support for UI text in the search dialog.
4//!
5//! # Using `Translations`
6//!
7//! The translations are available in YAML files in the `locales` directory,
8//! loaded through the `rust-i18n` crate. Application code does not call
9//! `rust-i18n`'s `t!` macro directly — it is not part of this crate's public
10//! API. Instead, look up translated strings through [`Translations`]:
11//!
12//! ```
13//! use iced_code_editor::{Language, Translations};
14//!
15//! let translations = Translations::new(Language::English);
16//! assert_eq!(translations.search_placeholder(), "Search...");
17//! ```
18
19/// Supported languages for the code editor UI.
20///
21/// # Examples
22///
23/// ```
24/// use iced_code_editor::Language;
25///
26/// let lang = Language::English;
27/// assert_eq!(lang, Language::default());
28/// ```
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
30pub enum Language {
31 /// English language
32 #[default]
33 English,
34 /// French language
35 French,
36 /// Spanish language
37 Spanish,
38 /// German language
39 German,
40 /// Italian language
41 Italian,
42 /// Portuguese (Brazilian) language
43 PortugueseBR,
44 /// Portuguese (European) language
45 PortuguesePT,
46 /// Simplified Chinese language
47 ChineseSimplified,
48}
49
50impl Language {
51 /// Returns the locale code for this language.
52 ///
53 /// # Examples
54 ///
55 /// ```
56 /// use iced_code_editor::Language;
57 ///
58 /// assert_eq!(Language::English.to_locale(), "en");
59 /// assert_eq!(Language::French.to_locale(), "fr");
60 /// assert_eq!(Language::Spanish.to_locale(), "es");
61 /// assert_eq!(Language::German.to_locale(), "de");
62 /// assert_eq!(Language::Italian.to_locale(), "it");
63 /// assert_eq!(Language::PortugueseBR.to_locale(), "pt-BR");
64 /// assert_eq!(Language::PortuguesePT.to_locale(), "pt-PT");
65 /// ```
66 #[must_use]
67 pub const fn to_locale(self) -> &'static str {
68 match self {
69 Self::English => "en",
70 Self::French => "fr",
71 Self::Spanish => "es",
72 Self::German => "de",
73 Self::Italian => "it",
74 Self::PortugueseBR => "pt-BR",
75 Self::PortuguesePT => "pt-PT",
76 Self::ChineseSimplified => "zh-CN",
77 }
78 }
79}
80
81/// Provides translated text strings for UI elements.
82///
83/// This struct contains all UI text translations used in the search dialog,
84/// including placeholders, tooltips, and labels.
85///
86/// # Examples
87///
88/// ```
89/// use iced_code_editor::{Language, Translations};
90///
91/// let translations = Translations::new(Language::French);
92/// assert_eq!(translations.search_placeholder(), "Rechercher...");
93/// ```
94#[derive(Debug, Clone, Copy, Default)]
95pub struct Translations {
96 language: Language,
97}
98
99impl Translations {
100 /// Creates a new `Translations` instance with the specified language.
101 ///
102 /// This sets the global rust-i18n locale to the specified language.
103 ///
104 /// # Examples
105 ///
106 /// ```
107 /// use iced_code_editor::{Language, Translations};
108 ///
109 /// let translations = Translations::new(Language::Spanish);
110 /// assert_eq!(translations.language(), Language::Spanish);
111 /// ```
112 #[must_use]
113 pub fn new(language: Language) -> Self {
114 rust_i18n::set_locale(language.to_locale());
115 Self { language }
116 }
117
118 /// Returns the current language.
119 ///
120 /// # Examples
121 ///
122 /// ```
123 /// use iced_code_editor::{Language, Translations};
124 ///
125 /// let translations = Translations::new(Language::French);
126 /// assert_eq!(translations.language(), Language::French);
127 /// ```
128 #[must_use]
129 pub const fn language(&self) -> Language {
130 self.language
131 }
132
133 /// Sets the language for translations.
134 ///
135 /// This updates the global rust-i18n locale.
136 ///
137 /// # Examples
138 ///
139 /// ```
140 /// use iced_code_editor::{Language, Translations};
141 ///
142 /// let mut translations = Translations::new(Language::English);
143 /// translations.set_language(Language::Spanish);
144 /// assert_eq!(translations.language(), Language::Spanish);
145 /// ```
146 pub fn set_language(&mut self, language: Language) {
147 self.language = language;
148 rust_i18n::set_locale(language.to_locale());
149 }
150
151 /// Returns the placeholder text for the search input field.
152 ///
153 /// # Examples
154 ///
155 /// ```
156 /// use iced_code_editor::{Language, Translations};
157 ///
158 /// let en = Translations::new(Language::English);
159 /// assert_eq!(en.search_placeholder(), "Search...");
160 ///
161 /// let fr = Translations::new(Language::French);
162 /// assert_eq!(fr.search_placeholder(), "Rechercher...");
163 /// ```
164 #[must_use]
165 pub fn search_placeholder(&self) -> String {
166 rust_i18n::t!("search.placeholder", locale = self.language.to_locale())
167 .into_owned()
168 }
169
170 /// Returns the placeholder text for the replace input field.
171 ///
172 /// # Examples
173 ///
174 /// ```
175 /// use iced_code_editor::{Language, Translations};
176 ///
177 /// let es = Translations::new(Language::Spanish);
178 /// assert_eq!(es.replace_placeholder(), "Reemplazar...");
179 /// ```
180 #[must_use]
181 pub fn replace_placeholder(&self) -> String {
182 rust_i18n::t!("replace.placeholder", locale = self.language.to_locale())
183 .into_owned()
184 }
185
186 /// Returns the label text for the case sensitive checkbox.
187 ///
188 /// # Examples
189 ///
190 /// ```
191 /// use iced_code_editor::{Language, Translations};
192 ///
193 /// let fr = Translations::new(Language::French);
194 /// assert_eq!(fr.case_sensitive_label(), "Sensible à la casse");
195 /// ```
196 #[must_use]
197 pub fn case_sensitive_label(&self) -> String {
198 rust_i18n::t!(
199 "settings.case_sensitive_label",
200 locale = self.language.to_locale()
201 )
202 .into_owned()
203 }
204
205 /// Returns the tooltip text for the previous match button.
206 ///
207 /// # Examples
208 ///
209 /// ```
210 /// use iced_code_editor::{Language, Translations};
211 ///
212 /// let en = Translations::new(Language::English);
213 /// assert_eq!(en.previous_match_tooltip(), "Previous match (Shift+F3)");
214 /// ```
215 #[must_use]
216 pub fn previous_match_tooltip(&self) -> String {
217 rust_i18n::t!(
218 "search.previous_match_tooltip",
219 locale = self.language.to_locale()
220 )
221 .into_owned()
222 }
223
224 /// Returns the tooltip text for the next match button.
225 ///
226 /// # Examples
227 ///
228 /// ```
229 /// use iced_code_editor::{Language, Translations};
230 ///
231 /// let es = Translations::new(Language::Spanish);
232 /// assert_eq!(es.next_match_tooltip(), "Siguiente coincidencia (F3 / Enter)");
233 /// ```
234 #[must_use]
235 pub fn next_match_tooltip(&self) -> String {
236 rust_i18n::t!(
237 "search.next_match_tooltip",
238 locale = self.language.to_locale()
239 )
240 .into_owned()
241 }
242
243 /// Returns the tooltip text for the close search dialog button.
244 ///
245 /// # Examples
246 ///
247 /// ```
248 /// use iced_code_editor::{Language, Translations};
249 ///
250 /// let fr = Translations::new(Language::French);
251 /// assert_eq!(fr.close_search_tooltip(), "Fermer la recherche (Échap)");
252 /// ```
253 #[must_use]
254 pub fn close_search_tooltip(&self) -> String {
255 rust_i18n::t!(
256 "search.close_tooltip",
257 locale = self.language.to_locale()
258 )
259 .into_owned()
260 }
261
262 /// Returns the tooltip text for the replace current match button.
263 ///
264 /// # Examples
265 ///
266 /// ```
267 /// use iced_code_editor::{Language, Translations};
268 ///
269 /// let en = Translations::new(Language::English);
270 /// assert_eq!(en.replace_current_tooltip(), "Replace current match");
271 /// ```
272 #[must_use]
273 pub fn replace_current_tooltip(&self) -> String {
274 rust_i18n::t!(
275 "replace.current_tooltip",
276 locale = self.language.to_locale()
277 )
278 .into_owned()
279 }
280
281 /// Returns the tooltip text for the replace all matches button.
282 ///
283 /// # Examples
284 ///
285 /// ```
286 /// use iced_code_editor::{Language, Translations};
287 ///
288 /// let es = Translations::new(Language::Spanish);
289 /// assert_eq!(es.replace_all_tooltip(), "Reemplazar todo");
290 /// ```
291 #[must_use]
292 pub fn replace_all_tooltip(&self) -> String {
293 rust_i18n::t!("replace.all_tooltip", locale = self.language.to_locale())
294 .into_owned()
295 }
296
297 /// Returns the context-menu label for undo.
298 ///
299 /// # Examples
300 ///
301 /// ```
302 /// use iced_code_editor::{Language, Translations};
303 ///
304 /// let en = Translations::new(Language::English);
305 /// assert_eq!(en.context_menu_undo(), "Undo");
306 ///
307 /// let fr = Translations::new(Language::French);
308 /// assert_eq!(fr.context_menu_undo(), "Annuler");
309 /// ```
310 #[must_use]
311 pub fn context_menu_undo(&self) -> String {
312 rust_i18n::t!("context_menu.undo", locale = self.language.to_locale())
313 .into_owned()
314 }
315
316 /// Returns the context-menu label for redo.
317 ///
318 /// # Examples
319 ///
320 /// ```
321 /// use iced_code_editor::{Language, Translations};
322 ///
323 /// let en = Translations::new(Language::English);
324 /// assert_eq!(en.context_menu_redo(), "Redo");
325 ///
326 /// let fr = Translations::new(Language::French);
327 /// assert_eq!(fr.context_menu_redo(), "Rétablir");
328 /// ```
329 #[must_use]
330 pub fn context_menu_redo(&self) -> String {
331 rust_i18n::t!("context_menu.redo", locale = self.language.to_locale())
332 .into_owned()
333 }
334
335 /// Returns the context-menu label for cut.
336 ///
337 /// # Examples
338 ///
339 /// ```
340 /// use iced_code_editor::{Language, Translations};
341 ///
342 /// let en = Translations::new(Language::English);
343 /// assert_eq!(en.context_menu_cut(), "Cut");
344 ///
345 /// let de = Translations::new(Language::German);
346 /// assert_eq!(de.context_menu_cut(), "Ausschneiden");
347 /// ```
348 #[must_use]
349 pub fn context_menu_cut(&self) -> String {
350 rust_i18n::t!("context_menu.cut", locale = self.language.to_locale())
351 .into_owned()
352 }
353
354 /// Returns the context-menu label for copy.
355 ///
356 /// # Examples
357 ///
358 /// ```
359 /// use iced_code_editor::{Language, Translations};
360 ///
361 /// let en = Translations::new(Language::English);
362 /// assert_eq!(en.context_menu_copy(), "Copy");
363 ///
364 /// let it = Translations::new(Language::Italian);
365 /// assert_eq!(it.context_menu_copy(), "Copia");
366 /// ```
367 #[must_use]
368 pub fn context_menu_copy(&self) -> String {
369 rust_i18n::t!("context_menu.copy", locale = self.language.to_locale())
370 .into_owned()
371 }
372
373 /// Returns the context-menu label for paste.
374 ///
375 /// # Examples
376 ///
377 /// ```
378 /// use iced_code_editor::{Language, Translations};
379 ///
380 /// let en = Translations::new(Language::English);
381 /// assert_eq!(en.context_menu_paste(), "Paste");
382 ///
383 /// let es = Translations::new(Language::Spanish);
384 /// assert_eq!(es.context_menu_paste(), "Pegar");
385 /// ```
386 #[must_use]
387 pub fn context_menu_paste(&self) -> String {
388 rust_i18n::t!("context_menu.paste", locale = self.language.to_locale())
389 .into_owned()
390 }
391
392 /// Returns the context-menu label for select all.
393 ///
394 /// # Examples
395 ///
396 /// ```
397 /// use iced_code_editor::{Language, Translations};
398 ///
399 /// let en = Translations::new(Language::English);
400 /// assert_eq!(en.context_menu_select_all(), "Select All");
401 ///
402 /// let fr = Translations::new(Language::French);
403 /// assert_eq!(fr.context_menu_select_all(), "Tout sélectionner");
404 /// ```
405 #[must_use]
406 pub fn context_menu_select_all(&self) -> String {
407 rust_i18n::t!(
408 "context_menu.select_all",
409 locale = self.language.to_locale()
410 )
411 .into_owned()
412 }
413
414 /// Returns the macOS context-menu label for revealing a file.
415 ///
416 /// Prefer [`Self::context_menu_reveal_in_file_manager`], which picks the
417 /// right one of the three platform wordings for you.
418 ///
419 /// # Examples
420 ///
421 /// ```
422 /// use iced_code_editor::{Language, Translations};
423 ///
424 /// let en = Translations::new(Language::English);
425 /// assert_eq!(en.context_menu_reveal_in_finder(), "Reveal in Finder");
426 /// ```
427 #[must_use]
428 pub fn context_menu_reveal_in_finder(&self) -> String {
429 rust_i18n::t!(
430 "context_menu.reveal_in_finder",
431 locale = self.language.to_locale()
432 )
433 .into_owned()
434 }
435
436 /// Returns the Windows context-menu label for revealing a file.
437 ///
438 /// Prefer [`Self::context_menu_reveal_in_file_manager`], which picks the
439 /// right one of the three platform wordings for you.
440 ///
441 /// # Examples
442 ///
443 /// ```
444 /// use iced_code_editor::{Language, Translations};
445 ///
446 /// let en = Translations::new(Language::English);
447 /// assert_eq!(
448 /// en.context_menu_reveal_in_file_explorer(),
449 /// "Reveal in File Explorer"
450 /// );
451 /// ```
452 #[must_use]
453 pub fn context_menu_reveal_in_file_explorer(&self) -> String {
454 rust_i18n::t!(
455 "context_menu.reveal_in_file_explorer",
456 locale = self.language.to_locale()
457 )
458 .into_owned()
459 }
460
461 /// Returns the Linux context-menu label for opening a file's parent folder.
462 ///
463 /// Worded as "open the containing folder" rather than "reveal", matching
464 /// how Linux file managers describe the action.
465 ///
466 /// # Examples
467 ///
468 /// ```
469 /// use iced_code_editor::{Language, Translations};
470 ///
471 /// let en = Translations::new(Language::English);
472 /// assert_eq!(
473 /// en.context_menu_open_containing_folder(),
474 /// "Open Containing Folder"
475 /// );
476 /// ```
477 #[must_use]
478 pub fn context_menu_open_containing_folder(&self) -> String {
479 rust_i18n::t!(
480 "context_menu.open_containing_folder",
481 locale = self.language.to_locale()
482 )
483 .into_owned()
484 }
485
486 /// Returns the platform-appropriate label for revealing a file.
487 ///
488 /// Resolves to "Reveal in Finder" on macOS, "Reveal in File Explorer" on
489 /// Windows, and "Open Containing Folder" elsewhere, so the menu matches
490 /// the wording users already know from their own file manager.
491 ///
492 /// # Examples
493 ///
494 /// ```
495 /// use iced_code_editor::{Language, Translations};
496 ///
497 /// let en = Translations::new(Language::English);
498 /// let label = en.context_menu_reveal_in_file_manager();
499 ///
500 /// // Whichever platform this runs on, it matches that platform's wording.
501 /// #[cfg(target_os = "macos")]
502 /// assert_eq!(label, en.context_menu_reveal_in_finder());
503 /// #[cfg(target_os = "windows")]
504 /// assert_eq!(label, en.context_menu_reveal_in_file_explorer());
505 /// #[cfg(not(any(target_os = "macos", target_os = "windows")))]
506 /// assert_eq!(label, en.context_menu_open_containing_folder());
507 /// ```
508 #[must_use]
509 pub fn context_menu_reveal_in_file_manager(&self) -> String {
510 if cfg!(target_os = "macos") {
511 self.context_menu_reveal_in_finder()
512 } else if cfg!(target_os = "windows") {
513 self.context_menu_reveal_in_file_explorer()
514 } else {
515 self.context_menu_open_containing_folder()
516 }
517 }
518}
519
520#[cfg(test)]
521mod tests {
522 use super::*;
523
524 #[test]
525 fn test_default_language() {
526 let translations = Translations::default();
527 assert_eq!(translations.language(), Language::English);
528 }
529
530 #[test]
531 fn test_new_with_language() {
532 let translations = Translations::new(Language::French);
533 assert_eq!(translations.language(), Language::French);
534 }
535
536 #[test]
537 fn test_set_language() {
538 let mut translations = Translations::new(Language::English);
539 translations.set_language(Language::Spanish);
540 assert_eq!(translations.language(), Language::Spanish);
541 }
542
543 #[test]
544 fn test_english_translations() {
545 let t = Translations::new(Language::English);
546 assert_eq!(t.search_placeholder(), "Search...");
547 assert_eq!(t.replace_placeholder(), "Replace...");
548 assert_eq!(t.case_sensitive_label(), "Case sensitive");
549 assert_eq!(t.previous_match_tooltip(), "Previous match (Shift+F3)");
550 assert_eq!(t.next_match_tooltip(), "Next match (F3 / Enter)");
551 assert_eq!(t.close_search_tooltip(), "Close search dialog (Esc)");
552 assert_eq!(t.replace_current_tooltip(), "Replace current match");
553 assert_eq!(t.replace_all_tooltip(), "Replace all matches");
554 }
555
556 #[test]
557 fn test_french_translations() {
558 let t = Translations::new(Language::French);
559 assert_eq!(t.search_placeholder(), "Rechercher...");
560 assert_eq!(t.replace_placeholder(), "Remplacer...");
561 assert_eq!(t.case_sensitive_label(), "Sensible à la casse");
562 assert_eq!(t.previous_match_tooltip(), "Résultat précédent (Maj+F3)");
563 assert_eq!(t.next_match_tooltip(), "Résultat suivant (F3 / Entrée)");
564 assert_eq!(t.close_search_tooltip(), "Fermer la recherche (Échap)");
565 assert_eq!(
566 t.replace_current_tooltip(),
567 "Remplacer l'occurrence actuelle"
568 );
569 assert_eq!(t.replace_all_tooltip(), "Tout remplacer");
570 }
571
572 #[test]
573 fn test_spanish_translations() {
574 let t = Translations::new(Language::Spanish);
575 assert_eq!(t.search_placeholder(), "Buscar...");
576 assert_eq!(t.replace_placeholder(), "Reemplazar...");
577 assert_eq!(t.case_sensitive_label(), "Distinguir mayúsculas");
578 assert_eq!(
579 t.previous_match_tooltip(),
580 "Coincidencia anterior (Mayús+F3)"
581 );
582 assert_eq!(
583 t.next_match_tooltip(),
584 "Siguiente coincidencia (F3 / Enter)"
585 );
586 assert_eq!(t.close_search_tooltip(), "Cerrar búsqueda (Esc)");
587 assert_eq!(
588 t.replace_current_tooltip(),
589 "Reemplazar coincidencia actual"
590 );
591 assert_eq!(t.replace_all_tooltip(), "Reemplazar todo");
592 }
593
594 #[test]
595 fn test_german_translations() {
596 let t = Translations::new(Language::German);
597 assert_eq!(t.search_placeholder(), "Suchen...");
598 assert_eq!(t.replace_placeholder(), "Ersetzen...");
599 assert_eq!(t.case_sensitive_label(), "Groß-/Kleinschreibung");
600 assert_eq!(
601 t.previous_match_tooltip(),
602 "Vorheriger Treffer (Umschalt+F3)"
603 );
604 assert_eq!(t.next_match_tooltip(), "Nächster Treffer (F3 / Enter)");
605 assert_eq!(t.close_search_tooltip(), "Suchdialog schließen (Esc)");
606 assert_eq!(t.replace_current_tooltip(), "Aktuellen Treffer ersetzen");
607 assert_eq!(t.replace_all_tooltip(), "Alle ersetzen");
608 }
609
610 #[test]
611 fn test_italian_translations() {
612 let t = Translations::new(Language::Italian);
613 assert_eq!(t.search_placeholder(), "Cerca...");
614 assert_eq!(t.replace_placeholder(), "Sostituisci...");
615 assert_eq!(t.case_sensitive_label(), "Distingui maiuscole");
616 assert_eq!(
617 t.previous_match_tooltip(),
618 "Risultato precedente (Maiusc+F3)"
619 );
620 assert_eq!(t.next_match_tooltip(), "Risultato successivo (F3 / Invio)");
621 assert_eq!(
622 t.close_search_tooltip(),
623 "Chiudi finestra di ricerca (Esc)"
624 );
625 assert_eq!(
626 t.replace_current_tooltip(),
627 "Sostituisci risultato corrente"
628 );
629 assert_eq!(t.replace_all_tooltip(), "Sostituisci tutto");
630 }
631
632 #[test]
633 fn test_portuguese_br_translations() {
634 let t = Translations::new(Language::PortugueseBR);
635 assert_eq!(t.search_placeholder(), "Pesquisar...");
636 assert_eq!(t.replace_placeholder(), "Substituir...");
637 assert_eq!(t.case_sensitive_label(), "Diferenciar maiúsculas");
638 assert_eq!(
639 t.previous_match_tooltip(),
640 "Correspondência anterior (Shift+F3)"
641 );
642 assert_eq!(
643 t.next_match_tooltip(),
644 "Próxima correspondência (F3 / Enter)"
645 );
646 assert_eq!(
647 t.close_search_tooltip(),
648 "Fechar diálogo de pesquisa (Esc)"
649 );
650 assert_eq!(
651 t.replace_current_tooltip(),
652 "Substituir correspondência atual"
653 );
654 assert_eq!(t.replace_all_tooltip(), "Substituir tudo");
655 }
656
657 #[test]
658 fn test_portuguese_pt_translations() {
659 let t = Translations::new(Language::PortuguesePT);
660 assert_eq!(t.search_placeholder(), "Pesquisar...");
661 assert_eq!(t.replace_placeholder(), "Substituir...");
662 assert_eq!(t.case_sensitive_label(), "Diferenciar maiúsculas");
663 assert_eq!(
664 t.previous_match_tooltip(),
665 "Correspondência anterior (Shift+F3)"
666 );
667 assert_eq!(
668 t.next_match_tooltip(),
669 "Próxima correspondência (F3 / Enter)"
670 );
671 assert_eq!(
672 t.close_search_tooltip(),
673 "Fechar diálogo de pesquisa (Esc)"
674 );
675 assert_eq!(
676 t.replace_current_tooltip(),
677 "Substituir correspondência actual"
678 );
679 assert_eq!(t.replace_all_tooltip(), "Substituir tudo");
680 }
681
682 #[test]
683 fn test_language_switching() {
684 let mut t = Translations::new(Language::English);
685 assert_eq!(t.search_placeholder(), "Search...");
686
687 t.set_language(Language::French);
688 assert_eq!(t.search_placeholder(), "Rechercher...");
689
690 t.set_language(Language::Spanish);
691 assert_eq!(t.search_placeholder(), "Buscar...");
692
693 t.set_language(Language::German);
694 assert_eq!(t.search_placeholder(), "Suchen...");
695
696 t.set_language(Language::Italian);
697 assert_eq!(t.search_placeholder(), "Cerca...");
698
699 t.set_language(Language::PortugueseBR);
700 assert_eq!(t.search_placeholder(), "Pesquisar...");
701
702 t.set_language(Language::PortuguesePT);
703 assert_eq!(t.search_placeholder(), "Pesquisar...");
704
705 t.set_language(Language::ChineseSimplified);
706 assert_eq!(t.search_placeholder(), "搜索...");
707 }
708
709 #[test]
710 fn test_context_menu_translations_cover_all_locales() {
711 let cases = [
712 (
713 Language::English,
714 [
715 "Undo",
716 "Redo",
717 "Cut",
718 "Copy",
719 "Paste",
720 "Select All",
721 "Reveal in Finder",
722 "Reveal in File Explorer",
723 "Open Containing Folder",
724 ],
725 ),
726 (
727 Language::French,
728 [
729 "Annuler",
730 "Rétablir",
731 "Couper",
732 "Copier",
733 "Coller",
734 "Tout sélectionner",
735 "Révéler dans le Finder",
736 "Afficher dans l'Explorateur de fichiers",
737 "Ouvrir le dossier contenant",
738 ],
739 ),
740 (
741 Language::Spanish,
742 [
743 "Deshacer",
744 "Rehacer",
745 "Cortar",
746 "Copiar",
747 "Pegar",
748 "Seleccionar todo",
749 "Mostrar en Finder",
750 "Mostrar en el Explorador de archivos",
751 "Abrir carpeta contenedora",
752 ],
753 ),
754 (
755 Language::German,
756 [
757 "Rückgängig",
758 "Wiederholen",
759 "Ausschneiden",
760 "Kopieren",
761 "Einfügen",
762 "Alle auswählen",
763 "Im Finder anzeigen",
764 "Im Datei-Explorer anzeigen",
765 "Übergeordneten Ordner öffnen",
766 ],
767 ),
768 (
769 Language::Italian,
770 [
771 "Annulla azione",
772 "Ripeti",
773 "Taglia",
774 "Copia",
775 "Incolla",
776 "Seleziona tutto",
777 "Visualizza in Finder",
778 "Visualizza in Esplora file",
779 "Apri cartella superiore",
780 ],
781 ),
782 (
783 Language::PortugueseBR,
784 [
785 "Desfazer",
786 "Refazer",
787 "Recortar",
788 "Copiar",
789 "Colar",
790 "Selecionar Tudo",
791 "Revelar no Finder",
792 "Revelar no Explorador de Arquivos",
793 "Abrir a Pasta Que Contém",
794 ],
795 ),
796 (
797 Language::PortuguesePT,
798 [
799 "Anular",
800 "Refazer",
801 "Cortar",
802 "Copiar",
803 "Colar",
804 "Selecionar tudo",
805 "Mostrar no Finder",
806 "Mostrar no Explorador de Ficheiros",
807 "Abrir pasta contentora",
808 ],
809 ),
810 (
811 Language::ChineseSimplified,
812 [
813 "撤消",
814 "恢复",
815 "剪切",
816 "复制",
817 "粘贴",
818 "选择全部",
819 "在访达中显示",
820 "在文件资源管理器中显示",
821 "打开所在的文件夹",
822 ],
823 ),
824 ];
825
826 for (language, expected) in cases {
827 let translations = Translations::new(language);
828 assert_eq!(translations.context_menu_undo(), expected[0]);
829 assert_eq!(translations.context_menu_redo(), expected[1]);
830 assert_eq!(translations.context_menu_cut(), expected[2]);
831 assert_eq!(translations.context_menu_copy(), expected[3]);
832 assert_eq!(translations.context_menu_paste(), expected[4]);
833 assert_eq!(translations.context_menu_select_all(), expected[5]);
834 assert_eq!(
835 translations.context_menu_reveal_in_finder(),
836 expected[6]
837 );
838 assert_eq!(
839 translations.context_menu_reveal_in_file_explorer(),
840 expected[7]
841 );
842 assert_eq!(
843 translations.context_menu_open_containing_folder(),
844 expected[8]
845 );
846 }
847 }
848}