Skip to main content

functora_core/
messages.rs

1use crate::i18n::{I18N, Language};
2use crate::white_label::{FUNCTORA_EMAIL, FUNCTORA_ORG};
3use std::env::VarError;
4use std::sync::mpsc::RecvError;
5
6#[derive(Clone, Debug, PartialEq)]
7pub enum Msg {
8    Copied,
9    Pasted,
10    About,
11    License,
12    Select,
13    Search,
14    Password,
15    PasswordPlaceholder,
16    Paste,
17    Copy,
18    Loading,
19    ErrorTitle(String),
20    EnvError(VarError),
21    ChannelError(RecvError),
22    NotJsonObject(String),
23    #[cfg(target_os = "android")]
24    JniError(String),
25    ErrorTitleLabel,
26    PasswordRequired,
27    ClipboardWriteError(String),
28    ClipboardReadError(String),
29    CameraNotAvailable(String),
30    CameraPermissionDenied(String),
31    Back,
32    Home,
33    DonateGreeting,
34    DonateIntro,
35    Stage(crate::progress::Stage),
36    Copyright,
37    AllRightsReserved,
38    ByContinuing,
39    YouAgree,
40    TermsOfService,
41    TermsOfServiceTitle,
42    PrivacyPolicyAnd,
43    PrivacyPolicyTitle,
44    VersionLabel,
45    Application,
46    Theme,
47    Donate,
48    DonateLink,
49    And,
50    FooterShareWord,
51    FooterAppWord,
52    LanguageFlag(Language),
53    LanguageName(Language),
54    LicenseText,
55    PrivacyText,
56    CopyAppLink,
57    ShareAppLink,
58    Sent,
59    SourceCodeButton,
60    AuthorButton,
61    JoinTestingButton,
62    GooglePlayButton,
63    DownloadApkButton,
64    AboutAndroidBeta1,
65    AboutAndroidBetaLink1,
66    AboutAndroidBeta2,
67    AboutAndroidBetaLink2,
68    AboutAndroidBeta3,
69    AboutAndroidBetaLink3,
70    AboutAndroidBeta4,
71    PwaInstallPrompt,
72    PwaInstallSuccess,
73    PwaInstallRejected,
74    PwaInstallUnavailable,
75    PwaInstallIos,
76    PwaInstallMac,
77    CipherAesLabel,
78    CipherChaChaLabel,
79    PickingFiles,
80    FilesAttached(usize),
81    Cancel,
82    Start,
83    Stop,
84    PickImage,
85    Clear,
86    Preparing,
87    Cancelling,
88    CameraStarting,
89    CameraOff,
90    Decoded,
91}
92
93impl I18N for Msg {
94    fn render_eng(&self) -> String {
95        match self {
96            Self::Copied => "Copied!".into(),
97            Self::Pasted => "Pasted!".into(),
98            Self::About => "About".into(),
99            Self::License => "License".into(),
100            Self::Select => "Select...".into(),
101            Self::Search => "Search...".into(),
102            Self::Password => "Password".into(),
103            Self::PasswordPlaceholder => "Enter password".into(),
104            Self::Paste => "Paste".into(),
105            Self::Copy => "Copy".into(),
106            Self::Loading => "Loading...".into(),
107            Self::ErrorTitle(e) => format!("Error: {e}"),
108            Self::EnvError(e) => format!("Environment variable error: {e}"),
109            Self::ChannelError(e) => format!("Channel receive error: {e}"),
110            Self::NotJsonObject(e) => format!("Expected JSON object, got: {e}"),
111            #[cfg(target_os = "android")]
112            Self::JniError(e) => format!("JNI error: {e}"),
113            Self::ErrorTitleLabel => "Error".into(),
114            Self::PasswordRequired => "Password is required for encryption".into(),
115            Self::ClipboardWriteError(e) => format!("Failed to copy to clipboard: {e}"),
116            Self::ClipboardReadError(e) => format!("Failed to read from clipboard: {e}"),
117            Self::CameraNotAvailable(e) => crate::Error::CameraNotAvailable(e.clone()).render_eng(),
118            Self::CameraPermissionDenied(e) => crate::Error::CameraPermissionDenied(e.clone()).render_eng(),
119            Self::Back => "Back".into(),
120            Self::Home => "Home".into(),
121            Self::DonateGreeting => "Hello, User!".into(),
122            Self::DonateIntro => {
123                "I'm Functora, the creator of this software. If you're enjoying it, a donation would be greatly appreciated. Sincerely yours, Functora.".into()
124            }
125            Self::Stage(s) => match s {
126                crate::progress::Stage::Attach => "Attaching files...".into(),
127                crate::progress::Stage::Zip => "Zipping files...".into(),
128                crate::progress::Stage::Encrypt => "Encrypting...".into(),
129                crate::progress::Stage::Decrypt => "Decrypting...".into(),
130                crate::progress::Stage::Unzip => "Unzipping...".into(),
131                crate::progress::Stage::Download => "Saving...".into(),
132                crate::progress::Stage::Preview => "Preparing preview...".into(),
133            },
134            Self::Copyright => "©".into(),
135            Self::AllRightsReserved => "All rights reserved.".into(),
136            Self::ByContinuing => "By continuing to use this software, you agree to the".into(),
137            Self::YouAgree | Self::And => "and".into(),
138            Self::TermsOfService | Self::TermsOfServiceTitle => "Terms of Service".into(),
139            Self::PrivacyPolicyAnd | Self::PrivacyPolicyTitle => "Privacy Policy".into(),
140            Self::VersionLabel => "Version".into(),
141            Self::Application => "Application".into(),
142            Self::Theme => "Theme".into(),
143            Self::Donate | Self::DonateLink => "Donate".into(),
144            Self::FooterShareWord => "Share".into(),
145            Self::FooterAppWord => "app".into(),
146            Self::LanguageFlag(Language::Eng) => "🇬🇧".into(),
147            Self::LanguageFlag(Language::Spa) => "🇪🇸".into(),
148            Self::LanguageFlag(Language::Rus) => "🇷🇺".into(),
149            Self::LanguageFlag(_) => "🌐".into(),
150            Self::LanguageName(Language::Eng) => "English".into(),
151            Self::LanguageName(Language::Spa) => "Español".into(),
152            Self::LanguageName(Language::Rus) => "Русский".into(),
153            Self::LanguageName(_) => "Unknown".into(),
154            Self::LicenseText => crate::white_label::license_text(FUNCTORA_ORG, Language::Eng),
155            Self::PrivacyText => {
156                crate::white_label::privacy_text(FUNCTORA_ORG, FUNCTORA_EMAIL, Language::Eng)
157            }
158            Self::CopyAppLink => "Copy link".into(),
159            Self::ShareAppLink => "Share app".into(),
160            Self::Sent => "Sent!".into(),
161            Self::SourceCodeButton => "Source code".into(),
162            Self::AuthorButton => "Author".into(),
163            Self::JoinTestingButton => "Join testing".into(),
164            Self::GooglePlayButton => "Google Play".into(),
165            Self::DownloadApkButton => "Save APK".into(),
166            Self::AboutAndroidBeta1 => "The Android app is in closed beta. To install it, join the".into(),
167            Self::AboutAndroidBetaLink1 => "closed beta".into(),
168            Self::AboutAndroidBeta2 => "group and then install the app from".into(),
169            Self::AboutAndroidBetaLink2 => "Google Play".into(),
170            Self::AboutAndroidBeta3 => ", or save the".into(),
171            Self::AboutAndroidBetaLink3 => "APK file".into(),
172            Self::AboutAndroidBeta4 => "directly.".into(),
173            Self::PwaInstallPrompt => "Install app".into(),
174            Self::PwaInstallSuccess => "App installed!".into(),
175            Self::PwaInstallRejected => "Installation cancelled".into(),
176            Self::PwaInstallUnavailable => "App installation is not available in this browser".into(),
177            Self::PwaInstallIos => "To install: tap Share, then 'Add to Home Screen'.".into(),
178            Self::PwaInstallMac => "To install: tap Share, then 'Add to Dock'.".into(),
179            Self::CipherAesLabel => "AES-256-GCM".into(),
180            Self::CipherChaChaLabel => "ChaCha20-Poly1305".into(),
181            Self::PickingFiles => "Picking files...".into(),
182            Self::FilesAttached(count) => format!("Files attached: {count}"),
183            Self::Cancel => "Cancel".into(),
184            Self::Start => "Start".into(),
185            Self::Stop => "Stop".into(),
186            Self::PickImage => "Pick Image".into(),
187            Self::Clear => "Clear".into(),
188            Self::Preparing => "Preparing...".into(),
189            Self::Cancelling => "Cancelling...".into(),
190            Self::CameraStarting => "Starting camera...".into(),
191            Self::CameraOff => "Camera off".into(),
192            Self::Decoded => "Decoded".into(),
193        }
194    }
195
196    fn render_spa(&self) -> String {
197        match self {
198            Self::Copied => "¡Copiado!".into(),
199            Self::Pasted => "¡Pegado!".into(),
200            Self::About => "Acerca de".into(),
201            Self::License => "Licencia".into(),
202            Self::Select => "Seleccionar...".into(),
203            Self::Search => "Buscar...".into(),
204            Self::Password => "Contraseña".into(),
205            Self::PasswordPlaceholder => "Ingresa contraseña".into(),
206            Self::Paste => "Pegar".into(),
207            Self::Copy => "Copiar".into(),
208            Self::Loading => "Cargando...".into(),
209            Self::ErrorTitle(e) => format!("Error: {e}"),
210            Self::EnvError(e) => format!("Error de variable de entorno: {e}"),
211            Self::ChannelError(e) => format!("Error de recepción en canal: {e}"),
212            Self::NotJsonObject(e) => format!("Se esperaba un objeto JSON, se obtuvo: {e}"),
213            #[cfg(target_os = "android")]
214            Self::JniError(e) => format!("Error JNI: {e}"),
215            Self::ErrorTitleLabel => "Error".into(),
216            Self::PasswordRequired => "Se requiere contraseña para el cifrado".into(),
217            Self::ClipboardWriteError(e) => format!("No se pudo copiar al portapapeles: {e}"),
218            Self::ClipboardReadError(e) => format!("No se pudo leer del portapapeles: {e}"),
219            Self::CameraNotAvailable(e) => crate::Error::CameraNotAvailable(e.clone()).render_spa(),
220            Self::CameraPermissionDenied(e) => crate::Error::CameraPermissionDenied(e.clone()).render_spa(),
221            Self::Back => "Atrás".into(),
222            Self::Home => "Inicio".into(),
223            Self::DonateGreeting => "¡Hola, Usuario!".into(),
224            Self::DonateIntro => {
225                "Soy Functora, el creador de este software. Si lo estás disfrutando, una donación sería muy apreciada. Atentamente, Functora.".into()
226            }
227            Self::Stage(s) => match s {
228                crate::progress::Stage::Attach => "Adjuntando archivos...".into(),
229                crate::progress::Stage::Zip => "Comprimiendo archivos...".into(),
230                crate::progress::Stage::Encrypt => "Cifrando...".into(),
231                crate::progress::Stage::Decrypt => "Descifrando...".into(),
232                crate::progress::Stage::Unzip => "Descomprimiendo...".into(),
233                crate::progress::Stage::Download => "Guardando...".into(),
234                crate::progress::Stage::Preview => "Preparando vista previa...".into(),
235            },
236            Self::Copyright => "©".into(),
237            Self::AllRightsReserved => "Todos los derechos reservados.".into(),
238            Self::ByContinuing => "Al continuar usando este software, aceptas los".into(),
239            Self::YouAgree => "y la".into(),
240            Self::TermsOfService | Self::TermsOfServiceTitle => "Términos de Servicio".into(),
241            Self::PrivacyPolicyAnd | Self::PrivacyPolicyTitle => "Política de Privacidad".into(),
242            Self::VersionLabel => "Versión".into(),
243            Self::Application => "Aplicación".into(),
244            Self::Theme => "Tema".into(),
245            Self::Donate | Self::DonateLink => "Donar".into(),
246            Self::And => "y".into(),
247            Self::FooterShareWord => "Compartir".into(),
248            Self::FooterAppWord => "la app".into(),
249            Self::LanguageFlag(Language::Eng) => "🇬🇧".into(),
250            Self::LanguageFlag(Language::Spa) => "🇪🇸".into(),
251            Self::LanguageFlag(Language::Rus) => "🇷🇺".into(),
252            Self::LanguageFlag(_) => "🌐".into(),
253            Self::LanguageName(Language::Eng) => "English".into(),
254            Self::LanguageName(Language::Spa) => "Español".into(),
255            Self::LanguageName(Language::Rus) => "Русский".into(),
256            Self::LanguageName(_) => "Unknown".into(),
257            Self::LicenseText => crate::white_label::license_text(FUNCTORA_ORG, Language::Spa),
258            Self::PrivacyText => {
259                crate::white_label::privacy_text(FUNCTORA_ORG, FUNCTORA_EMAIL, Language::Spa)
260            }
261            Self::CopyAppLink => "Copiar enlace".into(),
262            Self::ShareAppLink => "Compartir la app".into(),
263            Self::Sent => "¡Enviado!".into(),
264            Self::SourceCodeButton => "Código fuente".into(),
265            Self::AuthorButton => "Autor".into(),
266            Self::JoinTestingButton => "Unirse a prueba".into(),
267            Self::GooglePlayButton => "Google Play".into(),
268            Self::DownloadApkButton => "Guardar APK".into(),
269            Self::AboutAndroidBeta1 => "La aplicación de Android está en beta cerrada. Para instalarla, únase al grupo de".into(),
270            Self::AboutAndroidBetaLink1 => "beta cerrada".into(),
271            Self::AboutAndroidBeta2 => "y luego instale la aplicación desde".into(),
272            Self::AboutAndroidBetaLink2 => "Google Play".into(),
273            Self::AboutAndroidBeta3 => ", o guarde el".into(),
274            Self::AboutAndroidBetaLink3 => "archivo APK".into(),
275            Self::AboutAndroidBeta4 => "directamente.".into(),
276            Self::PwaInstallPrompt => "Instalar app".into(),
277            Self::PwaInstallSuccess => "¡App instalada!".into(),
278            Self::PwaInstallRejected => "Instalación cancelada".into(),
279            Self::PwaInstallUnavailable => "La instalación de la app no está disponible en este navegador".into(),
280            Self::PwaInstallIos => "Para instalar: toca Compartir y luego «Añadir a pantalla de inicio».".into(),
281            Self::PwaInstallMac => "Para instalar: toca Compartir y luego «Añadir al Dock».".into(),
282            Self::CipherAesLabel => "AES-256-GCM".into(),
283            Self::CipherChaChaLabel => "ChaCha20-Poly1305".into(),
284            Self::PickingFiles => "Seleccionando archivos...".into(),
285            Self::FilesAttached(count) => format!("Archivos adjuntos: {count}"),
286            Self::Cancel => "Cancelar".into(),
287            Self::Start => "Iniciar".into(),
288            Self::Stop => "Detener".into(),
289            Self::PickImage => "Elegir imagen".into(),
290            Self::Clear => "Borrar".into(),
291            Self::Preparing => "Preparando...".into(),
292            Self::Cancelling => "Cancelando...".into(),
293            Self::CameraStarting => "Iniciando cámara...".into(),
294            Self::CameraOff => "Cámara apagada".into(),
295            Self::Decoded => "Decodificado".into(),
296        }
297    }
298
299    fn render_rus(&self) -> String {
300        match self {
301            Self::Copied => "Скопировано!".into(),
302            Self::Pasted => "Вставлено!".into(),
303            Self::About => "О приложении".into(),
304            Self::License => "Лицензия".into(),
305            Self::Select => "Выбрать...".into(),
306            Self::Search => "Поиск...".into(),
307            Self::Password => "Пароль".into(),
308            Self::PasswordPlaceholder => "Введите пароль".into(),
309            Self::Paste => "Вставить".into(),
310            Self::Copy => "Копировать".into(),
311            Self::Loading => "Загрузка...".into(),
312            Self::ErrorTitle(e) => format!("Ошибка: {e}"),
313            Self::EnvError(e) => format!("Ошибка переменной окружения: {e}"),
314            Self::ChannelError(e) => format!("Ошибка получения из канала: {e}"),
315            Self::NotJsonObject(e) => format!("Ожидался JSON-объект, получено: {e}"),
316            #[cfg(target_os = "android")]
317            Self::JniError(e) => format!("Ошибка JNI: {e}"),
318            Self::ErrorTitleLabel => "Ошибка".into(),
319            Self::PasswordRequired => "Для шифрования требуется пароль".into(),
320            Self::ClipboardWriteError(e) => format!("Не удалось скопировать в буфер обмена: {e}"),
321            Self::ClipboardReadError(e) => format!("Не удалось прочитать из буфера обмена: {e}"),
322            Self::CameraNotAvailable(e) => crate::Error::CameraNotAvailable(e.clone()).render_rus(),
323            Self::CameraPermissionDenied(e) => crate::Error::CameraPermissionDenied(e.clone()).render_rus(),
324            Self::Back => "Назад".into(),
325            Self::Home => "Главная".into(),
326            Self::DonateGreeting => "Здравствуйте, пользователь!".into(),
327            Self::DonateIntro => {
328                "Я Functora, создатель этого программного обеспечения. Если оно вам нравится, я буду очень признателен за пожертвование. С уважением, Functora.".into()
329            }
330            Self::Stage(s) => match s {
331                crate::progress::Stage::Attach => "Прикрепление файлов...".into(),
332                crate::progress::Stage::Zip => "Архивация файлов...".into(),
333                crate::progress::Stage::Encrypt => "Шифрование...".into(),
334                crate::progress::Stage::Decrypt => "Расшифровка...".into(),
335                crate::progress::Stage::Unzip => "Распаковка...".into(),
336                crate::progress::Stage::Download => "Сохранение...".into(),
337                crate::progress::Stage::Preview => "Подготовка предпросмотра...".into(),
338            },
339            Self::Copyright => "©".into(),
340            Self::AllRightsReserved => "Все права защищены.".into(),
341            Self::ByContinuing => "Продолжая использовать это программное обеспечение, вы соглашаетесь с".into(),
342            Self::YouAgree | Self::And => "и".into(),
343            Self::TermsOfService => "Условиями обслуживания".into(),
344            Self::TermsOfServiceTitle => "Условия обслуживания".into(),
345            Self::PrivacyPolicyAnd => "Политикой конфиденциальности".into(),
346            Self::PrivacyPolicyTitle => "Политика конфиденциальности".into(),
347            Self::VersionLabel => "Версия".into(),
348            Self::Application => "Приложение".into(),
349            Self::Theme => "Тема".into(),
350            Self::Donate => "Пожертвовать".into(),
351            Self::DonateLink => "Сделайте пожертвование".into(),
352            Self::FooterShareWord => "Поделитесь".into(),
353            Self::FooterAppWord => "приложением".into(),
354            Self::LanguageFlag(Language::Eng) => "🇬🇧".into(),
355            Self::LanguageFlag(Language::Spa) => "🇪🇸".into(),
356            Self::LanguageFlag(Language::Rus) => "🇷🇺".into(),
357            Self::LanguageFlag(_) => "🌐".into(),
358            Self::LanguageName(Language::Eng) => "English".into(),
359            Self::LanguageName(Language::Spa) => "Español".into(),
360            Self::LanguageName(Language::Rus) => "Русский".into(),
361            Self::LanguageName(_) => "Unknown".into(),
362            Self::LicenseText => crate::white_label::license_text(FUNCTORA_ORG, Language::Rus),
363            Self::PrivacyText => {
364                crate::white_label::privacy_text(FUNCTORA_ORG, FUNCTORA_EMAIL, Language::Rus)
365            }
366            Self::CopyAppLink => "Скопировать ссылку".into(),
367            Self::ShareAppLink => "Поделиться приложением".into(),
368            Self::Sent => "Отправлено!".into(),
369            Self::SourceCodeButton => "Исходный код".into(),
370            Self::AuthorButton => "Автор".into(),
371            Self::JoinTestingButton => "Вступить в бета-тест".into(),
372            Self::GooglePlayButton => "Google Play".into(),
373            Self::DownloadApkButton => "Сохранить APK".into(),
374            Self::AboutAndroidBeta1 => "Приложение Android в закрытом бета-тестировании. Чтобы установить его, вступите в группу".into(),
375            Self::AboutAndroidBetaLink1 => "бета-тестирования".into(),
376            Self::AboutAndroidBeta2 => ", затем установите приложение из".into(),
377            Self::AboutAndroidBetaLink2 => "Google Play".into(),
378            Self::AboutAndroidBeta3 => " или скачайте".into(),
379            Self::AboutAndroidBetaLink3 => "APK-файл".into(),
380            Self::AboutAndroidBeta4 => "напрямую.".into(),
381            Self::PwaInstallPrompt => "Установить приложение".into(),
382            Self::PwaInstallSuccess => "Приложение установлено!".into(),
383            Self::PwaInstallRejected => "Установка отменена".into(),
384            Self::PwaInstallUnavailable => "Установка приложения недоступна в этом браузере".into(),
385            Self::PwaInstallIos => "Чтобы установить: нажмите «Поделиться», затем «На экран \"Домой\"».".into(),
386            Self::PwaInstallMac => "Чтобы установить: нажмите «Поделиться», затем «Добавить в Dock».".into(),
387            Self::CipherAesLabel => "AES-256-GCM".into(),
388            Self::CipherChaChaLabel => "ChaCha20-Poly1305".into(),
389            Self::PickingFiles => "Выбор файлов...".into(),
390            Self::FilesAttached(count) => format!("Прикреплено файлов: {count}"),
391            Self::Cancel => "Отмена".into(),
392            Self::Start => "Начать".into(),
393            Self::Stop => "Остановить".into(),
394            Self::PickImage => "Выбрать изображение".into(),
395            Self::Clear => "Очистить".into(),
396            Self::Preparing => "Подготовка...".into(),
397            Self::Cancelling => "Отмена...".into(),
398            Self::CameraStarting => "Запуск камеры...".into(),
399            Self::CameraOff => "Камера выключена".into(),
400            Self::Decoded => "Декодировано".into(),
401        }
402    }
403}