lurq 0.65.1

A Rust UI toolkit with typed components, retained state, reactive signals, GPU rendering, and DevTools.
Documentation
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
//! What the tools of writing say by themselves: finding and replacing, a rich text editor's tools, a block of code,
//! a command palette, and what a Markdown document calls its notes. A part of the app's [`Locale`](super::Locale).

use std::sync::Arc;

use super::Plural;

/// What the tools of writing say by themselves, in a locale's words. Every field is the app's to replace.
///
/// ```
/// use lurq::core::Locale;
///
/// let locale = Locale::for_tag("es");
/// assert_eq!(&*locale.editing.replace_all, "Reemplazar todo");
/// assert_eq!(locale.count(&locale.editing.words, 1), "1 palabra");
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EditingWords {
  /// A find bar: what it is called and says empty, its fields, its buttons and its options.
  pub find: Arc<str>,
  pub replace: Arc<str>,
  pub previous_match: Arc<str>,
  pub next_match: Arc<str>,
  pub match_case: Arc<str>,
  pub match_whole_word: Arc<str>,
  pub use_regex: Arc<str>,
  pub replace_all: Arc<str>,
  pub toggle_replace: Arc<str>,
  pub search_options: Arc<str>,
  /// A rich text editor's toolbar, its menu of the kinds of paragraph, and its tools. A heading has `{level}`.
  pub formatting: Arc<str>,
  pub text_style: Arc<str>,
  pub paragraph: Arc<str>,
  pub heading: Arc<str>,
  pub code_block: Arc<str>,
  pub bold: Arc<str>,
  pub italic: Arc<str>,
  pub underline: Arc<str>,
  pub strikethrough: Arc<str>,
  pub bulleted_list: Arc<str>,
  pub numbered_list: Arc<str>,
  pub quote: Arc<str>,
  /// Code in a line of text, and what a block of code is called with no title and no language.
  pub code: Arc<str>,
  pub link: Arc<str>,
  pub image: Arc<str>,
  pub undo: Arc<str>,
  pub redo: Arc<str>,
  /// The menu of editing commands a finger opens, over text selected by touch or under three fingers' tap; with
  /// `undo`, `redo` and `common.select_all`.
  pub cut: Arc<str>,
  pub copy: Arc<str>,
  pub paste: Arc<str>,
  /// The field of a link's address, the button that takes the link away, and what the editor says of its
  /// shortcuts.
  pub paste_link: Arc<str>,
  pub remove_link: Arc<str>,
  pub markdown_shortcuts: Arc<str>,
  /// The count of an editor's words: "120 words".
  pub words: Plural,
  /// The button of a block of code, and what it says once the code is copied.
  pub copy_code: Arc<str>,
  pub copied: Arc<str>,
  /// What the button of a block of code says where the clipboard did not take the code.
  pub copy_failed: Arc<str>,
  /// What a command palette says until something is typed, and the hints of its keys.
  pub command_placeholder: Arc<str>,
  pub to_move: Arc<str>,
  pub to_run: Arc<str>,
  pub to_close: Arc<str>,
  /// The titles of a Markdown document's notes (`> [!NOTE]`).
  pub note: Arc<str>,
  pub tip: Arc<str>,
  pub important: Arc<str>,
  pub warning: Arc<str>,
  pub caution: Arc<str>,
  /// The way back from a footnote, with `{number}` for its reference.
  pub back_to_reference: Arc<str>,
}

impl EditingWords {
  pub fn english() -> Self {
    Self {
      find: "Find".into(),
      replace: "Replace".into(),
      previous_match: "Previous match".into(),
      next_match: "Next match".into(),
      match_case: "Match case".into(),
      match_whole_word: "Match whole word".into(),
      use_regex: "Use regular expression".into(),
      replace_all: "Replace all".into(),
      toggle_replace: "Toggle replace".into(),
      search_options: "Search options".into(),
      formatting: "Formatting".into(),
      text_style: "Text style".into(),
      paragraph: "Paragraph".into(),
      heading: "Heading {level}".into(),
      code_block: "Code block".into(),
      bold: "Bold".into(),
      italic: "Italic".into(),
      underline: "Underline".into(),
      strikethrough: "Strikethrough".into(),
      bulleted_list: "Bulleted list".into(),
      numbered_list: "Numbered list".into(),
      quote: "Quote".into(),
      code: "Code".into(),
      link: "Link".into(),
      image: "Image".into(),
      undo: "Undo".into(),
      redo: "Redo".into(),
      cut: "Cut".into(),
      copy: "Copy".into(),
      paste: "Paste".into(),
      paste_link: "Paste a link".into(),
      remove_link: "Remove link".into(),
      markdown_shortcuts: "Markdown shortcuts on".into(),
      words: Plural::two("{count} word", "{count} words"),
      copy_code: "Copy code".into(),
      copied: "Copied".into(),
      copy_failed: "Couldn't copy".into(),
      command_placeholder: "Type a command or search".into(),
      to_move: "to move".into(),
      to_run: "to run".into(),
      to_close: "to close".into(),
      note: "Note".into(),
      tip: "Tip".into(),
      important: "Important".into(),
      warning: "Warning".into(),
      caution: "Caution".into(),
      back_to_reference: "Back to the reference {number}".into(),
    }
  }

  /// The words of a language (`en`, `uk`, `de`, `fr`, `es`, `pl`); of any other, English.
  pub fn for_language(language: &str) -> Self {
    match language {
      "uk" => Self {
        find: "Знайти".into(),
        replace: "Замінити".into(),
        previous_match: "Попередній збіг".into(),
        next_match: "Наступний збіг".into(),
        match_case: "Враховувати регістр".into(),
        match_whole_word: "Лише цілі слова".into(),
        use_regex: "Регулярний вираз".into(),
        replace_all: "Замінити все".into(),
        toggle_replace: "Показати або сховати заміну".into(),
        search_options: "Параметри пошуку".into(),
        formatting: "Форматування".into(),
        text_style: "Стиль тексту".into(),
        paragraph: "Абзац".into(),
        heading: "Заголовок {level}".into(),
        code_block: "Блок коду".into(),
        bold: "Жирний".into(),
        italic: "Курсив".into(),
        underline: "Підкреслений".into(),
        strikethrough: "Закреслений".into(),
        bulleted_list: "Маркований список".into(),
        numbered_list: "Нумерований список".into(),
        quote: "Цитата".into(),
        code: "Код".into(),
        link: "Посилання".into(),
        image: "Зображення".into(),
        undo: "Скасувати".into(),
        redo: "Повторити".into(),
        cut: "Вирізати".into(),
        copy: "Копіювати".into(),
        paste: "Вставити".into(),
        paste_link: "Вставте посилання".into(),
        remove_link: "Вилучити посилання".into(),
        markdown_shortcuts: "Скорочення Markdown увімкнено".into(),
        words: Plural::three("{count} слово", "{count} слова", "{count} слів"),
        copy_code: "Копіювати код".into(),
        copied: "Скопійовано".into(),
        copy_failed: "Не вдалося скопіювати".into(),
        command_placeholder: "Введіть команду або пошуковий запит".into(),
        to_move: "перейти".into(),
        to_run: "виконати".into(),
        to_close: "закрити".into(),
        note: "Примітка".into(),
        tip: "Порада".into(),
        important: "Важливо".into(),
        warning: "Попередження".into(),
        caution: "Обережно".into(),
        back_to_reference: "Назад до посилання {number}".into(),
      },
      "de" => Self {
        find: "Suchen".into(),
        replace: "Ersetzen".into(),
        previous_match: "Vorheriger Treffer".into(),
        next_match: "Nächster Treffer".into(),
        match_case: "Groß-/Kleinschreibung beachten".into(),
        match_whole_word: "Nur ganzes Wort".into(),
        use_regex: "Regulären Ausdruck verwenden".into(),
        replace_all: "Alle ersetzen".into(),
        toggle_replace: "Ersetzen ein-/ausblenden".into(),
        search_options: "Suchoptionen".into(),
        formatting: "Formatierung".into(),
        text_style: "Textstil".into(),
        paragraph: "Absatz".into(),
        heading: "Überschrift {level}".into(),
        code_block: "Codeblock".into(),
        bold: "Fett".into(),
        italic: "Kursiv".into(),
        underline: "Unterstrichen".into(),
        strikethrough: "Durchgestrichen".into(),
        bulleted_list: "Aufzählung".into(),
        numbered_list: "Nummerierte Liste".into(),
        quote: "Zitat".into(),
        code: "Code".into(),
        link: "Link".into(),
        image: "Bild".into(),
        undo: "Rückgängig".into(),
        redo: "Wiederholen".into(),
        cut: "Ausschneiden".into(),
        copy: "Kopieren".into(),
        paste: "Einsetzen".into(),
        paste_link: "Link einfügen".into(),
        remove_link: "Link entfernen".into(),
        markdown_shortcuts: "Markdown-Kürzel aktiv".into(),
        words: Plural::two("{count} Wort", "{count} Wörter"),
        copy_code: "Code kopieren".into(),
        copied: "Kopiert".into(),
        copy_failed: "Kopieren fehlgeschlagen".into(),
        command_placeholder: "Befehl eingeben oder suchen".into(),
        to_move: "zum Bewegen".into(),
        to_run: "zum Ausführen".into(),
        to_close: "zum Schließen".into(),
        note: "Hinweis".into(),
        tip: "Tipp".into(),
        important: "Wichtig".into(),
        warning: "Warnung".into(),
        caution: "Vorsicht".into(),
        back_to_reference: "Zurück zum Verweis {number}".into(),
      },
      "fr" => Self {
        find: "Rechercher".into(),
        replace: "Remplacer".into(),
        previous_match: "Résultat précédent".into(),
        next_match: "Résultat suivant".into(),
        match_case: "Respecter la casse".into(),
        match_whole_word: "Mot entier uniquement".into(),
        use_regex: "Utiliser une expression régulière".into(),
        replace_all: "Tout remplacer".into(),
        toggle_replace: "Afficher ou masquer le remplacement".into(),
        search_options: "Options de recherche".into(),
        formatting: "Mise en forme".into(),
        text_style: "Style de texte".into(),
        paragraph: "Paragraphe".into(),
        heading: "Titre {level}".into(),
        code_block: "Bloc de code".into(),
        bold: "Gras".into(),
        italic: "Italique".into(),
        underline: "Souligné".into(),
        strikethrough: "Barré".into(),
        bulleted_list: "Liste à puces".into(),
        numbered_list: "Liste numérotée".into(),
        quote: "Citation".into(),
        code: "Code".into(),
        link: "Lien".into(),
        image: "Image".into(),
        undo: "Annuler".into(),
        redo: "Rétablir".into(),
        cut: "Couper".into(),
        copy: "Copier".into(),
        paste: "Coller".into(),
        paste_link: "Collez un lien".into(),
        remove_link: "Supprimer le lien".into(),
        markdown_shortcuts: "Raccourcis Markdown activés".into(),
        words: Plural::two("{count} mot", "{count} mots"),
        copy_code: "Copier le code".into(),
        copied: "Copié".into(),
        copy_failed: "Échec de la copie".into(),
        command_placeholder: "Saisissez une commande ou recherchez".into(),
        to_move: "pour naviguer".into(),
        to_run: "pour exécuter".into(),
        to_close: "pour fermer".into(),
        note: "Remarque".into(),
        tip: "Astuce".into(),
        important: "Important".into(),
        warning: "Avertissement".into(),
        caution: "Attention".into(),
        back_to_reference: "Retour à la référence {number}".into(),
      },
      "es" => Self {
        find: "Buscar".into(),
        replace: "Reemplazar".into(),
        previous_match: "Coincidencia anterior".into(),
        next_match: "Coincidencia siguiente".into(),
        match_case: "Distinguir mayúsculas y minúsculas".into(),
        match_whole_word: "Solo palabras completas".into(),
        use_regex: "Usar expresión regular".into(),
        replace_all: "Reemplazar todo".into(),
        toggle_replace: "Mostrar u ocultar reemplazo".into(),
        search_options: "Opciones de búsqueda".into(),
        formatting: "Formato".into(),
        text_style: "Estilo de texto".into(),
        paragraph: "Párrafo".into(),
        heading: "Título {level}".into(),
        code_block: "Bloque de código".into(),
        bold: "Negrita".into(),
        italic: "Cursiva".into(),
        underline: "Subrayado".into(),
        strikethrough: "Tachado".into(),
        bulleted_list: "Lista con viñetas".into(),
        numbered_list: "Lista numerada".into(),
        quote: "Cita".into(),
        code: "Código".into(),
        link: "Enlace".into(),
        image: "Imagen".into(),
        undo: "Deshacer".into(),
        redo: "Rehacer".into(),
        cut: "Cortar".into(),
        copy: "Copiar".into(),
        paste: "Pegar".into(),
        paste_link: "Pega un enlace".into(),
        remove_link: "Quitar enlace".into(),
        markdown_shortcuts: "Atajos de Markdown activados".into(),
        words: Plural::two("{count} palabra", "{count} palabras"),
        copy_code: "Copiar código".into(),
        copied: "Copiado".into(),
        copy_failed: "No se pudo copiar".into(),
        command_placeholder: "Escribe un comando o busca".into(),
        to_move: "para moverte".into(),
        to_run: "para ejecutar".into(),
        to_close: "para cerrar".into(),
        note: "Nota".into(),
        tip: "Consejo".into(),
        important: "Importante".into(),
        warning: "Advertencia".into(),
        caution: "Precaución".into(),
        back_to_reference: "Volver a la referencia {number}".into(),
      },
      "pl" => Self {
        find: "Znajdź".into(),
        replace: "Zamień".into(),
        previous_match: "Poprzednie dopasowanie".into(),
        next_match: "Następne dopasowanie".into(),
        match_case: "Uwzględniaj wielkość liter".into(),
        match_whole_word: "Tylko całe wyrazy".into(),
        use_regex: "Użyj wyrażenia regularnego".into(),
        replace_all: "Zamień wszystko".into(),
        toggle_replace: "Pokaż lub ukryj zamianę".into(),
        search_options: "Opcje wyszukiwania".into(),
        formatting: "Formatowanie".into(),
        text_style: "Styl tekstu".into(),
        paragraph: "Akapit".into(),
        heading: "Nagłówek {level}".into(),
        code_block: "Blok kodu".into(),
        bold: "Pogrubienie".into(),
        italic: "Kursywa".into(),
        underline: "Podkreślenie".into(),
        strikethrough: "Przekreślenie".into(),
        bulleted_list: "Lista punktowana".into(),
        numbered_list: "Lista numerowana".into(),
        quote: "Cytat".into(),
        code: "Kod".into(),
        link: "Link".into(),
        image: "Obraz".into(),
        undo: "Cofnij".into(),
        redo: "Ponów".into(),
        cut: "Wytnij".into(),
        copy: "Kopiuj".into(),
        paste: "Wklej".into(),
        paste_link: "Wklej link".into(),
        remove_link: "Usuń link".into(),
        markdown_shortcuts: "Skróty Markdown włączone".into(),
        words: Plural::three("{count} słowo", "{count} słowa", "{count} słów"),
        copy_code: "Kopiuj kod".into(),
        copied: "Skopiowano".into(),
        copy_failed: "Nie udało się skopiować".into(),
        command_placeholder: "Wpisz polecenie lub wyszukaj".into(),
        to_move: "aby przejść".into(),
        to_run: "aby wykonać".into(),
        to_close: "aby zamknąć".into(),
        note: "Uwaga".into(),
        tip: "Wskazówka".into(),
        important: "Ważne".into(),
        warning: "Ostrzeżenie".into(),
        caution: "Przestroga".into(),
        back_to_reference: "Wróć do odwołania {number}".into(),
      },
      _ => Self::english(),
    }
  }
}

impl Default for EditingWords {
  fn default() -> Self {
    Self::english()
  }
}

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

  #[test]
  fn every_language_has_every_word_with_its_places() {
    for language in super::super::locale::LANGUAGES {
      let words = EditingWords::for_language(language);
      assert!(words.heading.contains("{level}"), "{language}");
      assert!(words.back_to_reference.contains("{number}"), "{language}");
      assert!(
        words.words.forms().iter().all(|form| form.contains("{count}")),
        "{language}"
      );
      assert!(!words.find.is_empty() && !words.caution.is_empty(), "{language}");
    }
    assert_eq!(EditingWords::for_language("xx"), EditingWords::english());
  }
}