Skip to content

Commit f6816b9

Browse files
committed
wip
1 parent ed1fc9a commit f6816b9

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

rust/cryptonote/src/i18n.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ impl Language {
2727

2828
#[derive(Clone)]
2929
pub struct Translations {
30+
pub note: &'static str,
3031
pub note_placeholder: &'static str,
32+
pub mode: &'static str,
3133
pub no_encryption: &'static str,
3234
pub password_encryption: &'static str,
33-
pub cipher: &'static str,
35+
pub algorithm: &'static str,
3436
pub password: &'static str,
3537
pub password_placeholder: &'static str,
3638
pub generate_button: &'static str,
@@ -60,10 +62,12 @@ pub struct Translations {
6062
pub fn get_translations(lang: Language) -> Translations {
6163
match lang {
6264
Language::English => Translations {
65+
note: "Note",
6366
note_placeholder: "Enter your note here...",
67+
mode: "Mode",
6468
no_encryption: "No encryption (plaintext)",
6569
password_encryption: "Password encryption",
66-
cipher: "Cipher",
70+
algorithm: "Algorithm",
6771
password: "Password",
6872
password_placeholder: "Enter password",
6973
generate_button: "Generate Shareable Link",
@@ -90,10 +94,12 @@ pub fn get_translations(lang: Language) -> Translations {
9094
url_error: "Invalid URL format",
9195
},
9296
Language::Spanish => Translations {
97+
note: "Nota",
9398
note_placeholder: "Escribe tu nota aquí...",
99+
mode: "Modo",
94100
no_encryption: "Sin cifrado (texto plano)",
95101
password_encryption: "Cifrado con contraseña",
96-
cipher: "Cifrado",
102+
algorithm: "Algoritmo",
97103
password: "Contraseña",
98104
password_placeholder: "Ingresa contraseña",
99105
generate_button: "Generar Enlace Compartible",
@@ -120,10 +126,12 @@ pub fn get_translations(lang: Language) -> Translations {
120126
url_error: "Formato de URL inválido",
121127
},
122128
Language::Russian => Translations {
129+
note: "Заметка",
123130
note_placeholder: "Введите вашу заметку здесь...",
131+
mode: "Режим",
124132
no_encryption: "Без шифрования (открытый текст)",
125133
password_encryption: "Шифрование паролем",
126-
cipher: "Шифр",
134+
algorithm: "Алгоритм",
127135
password: "Пароль",
128136
password_placeholder: "Введите пароль",
129137
generate_button: "Создать Ссылку для Обмена",

rust/cryptonote/src/views/home.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ pub fn Home() -> Element {
1111
let t = get_translations(language());
1212

1313
let mut note_text = use_signal(|| String::new());
14-
let mut encryption = use_signal(|| Option::<CipherType>::None);
14+
let mut encryption =
15+
use_signal(|| Option::<CipherType>::None);
1516
let mut password = use_signal(|| String::new());
1617
let mut generated_url =
1718
use_signal(|| Option::<String>::None);
@@ -44,11 +45,12 @@ pub fn Home() -> Element {
4445
&pwd,
4546
cipher,
4647
) {
47-
Ok(encrypted) => NoteData::CipherText(encrypted),
48+
Ok(encrypted) => {
49+
NoteData::CipherText(encrypted)
50+
}
4851
Err(e) => {
49-
error_message.set(Some(
50-
e.localized(&t)
51-
));
52+
error_message
53+
.set(Some(e.localized(&t)));
5254
return;
5355
}
5456
}
@@ -70,59 +72,55 @@ pub fn Home() -> Element {
7072
Ok(url) => {
7173
match generate_qr_code(&url) {
7274
Ok(svg) => qr_code_svg.set(Some(svg)),
73-
Err(e) => {
74-
error_message.set(Some(
75-
e.localized(&t)
76-
))
77-
}
75+
Err(e) => error_message
76+
.set(Some(e.localized(&t))),
7877
}
7978
generated_url.set(Some(url));
8079
}
81-
Err(e) => error_message.set(Some(
82-
e.localized(&t)
83-
)),
80+
Err(e) => {
81+
error_message.set(Some(e.localized(&t)))
82+
}
8483
}
8584
};
8685

8786
rsx! {
8887
section {
8988
fieldset {
9089

91-
label { "{t.password}" }
90+
label { "{t.note}" }
9291
textarea {
9392
placeholder: "{t.note_placeholder}",
9493
rows: "8",
9594
value: "{note_text}",
9695
oninput: move |evt| note_text.set(evt.value()),
9796
}
9897

99-
br {}
98+
label { "{t.mode}" }
10099

101100
input {
102101
r#type: "radio",
103-
id: "enc_none",
104-
name: "encryption",
105102
value: "none",
106103
checked: encryption().is_none(),
107104
onchange: move |_| encryption.set(None),
108105
}
109-
label { r#for: "enc_none", "{t.no_encryption}" }
106+
label { "{t.no_encryption}" }
110107

111108
br {}
112109

113110
input {
114111
r#type: "radio",
115-
id: "enc_symmetric",
116-
name: "encryption",
117112
value: "symmetric",
118113
checked: encryption().is_some(),
119114
onchange: move |_| encryption.set(Some(CipherType::ChaCha20Poly1305)),
120115
}
121-
label { r#for: "enc_symmetric", "{t.password_encryption}" }
116+
label { "{t.password_encryption}" }
122117

123118
if let Some(cipher) = encryption() {
124119

125-
label { "{t.cipher}" }
120+
br {}
121+
br {}
122+
123+
label { "{t.algorithm}" }
126124
select {
127125
value: match cipher {
128126
CipherType::ChaCha20Poly1305 => "chacha20",

rust/cryptonote/src/views/view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn View() -> Element {
8686

8787
if let Some(enc) = encrypted_data() {
8888
p {
89-
strong { "{t.cipher}: " }
89+
strong { "{t.algorithm}: " }
9090
match enc.cipher {
9191
crate::crypto::CipherType::ChaCha20Poly1305 => "ChaCha20-Poly1305",
9292
crate::crypto::CipherType::Aes256Gcm => "AES-256-GCM",

0 commit comments

Comments
 (0)