Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions legacy/firmware/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void config_setLanguage(const char *lang) {
if (lang == NULL) {
return;
}
for (uint8_t i = 0; i < langs_len; i++) {
for (uint8_t i = 0; i < I18N_LANGUAGE_ITEMS; i++) {
if (strcmp(lang, i18n_lang_keys[i]) == 0) {
ui_language = i;
config_set(KEY_LANGUAGE, lang,
Expand Down Expand Up @@ -394,7 +394,7 @@ bool config_getLabel(char *dest, uint16_t dest_size) {

bool config_getLanguage(char *dest, uint16_t dest_size) {
if (sectrue == config_get_string(KEY_LANGUAGE, dest, &dest_size)) {
for (uint8_t i = 0; i < langs_len; i++) {
for (uint8_t i = 0; i < I18N_LANGUAGE_ITEMS; i++) {
if (strcmp(dest, i18n_lang_keys[i]) == 0) {
ui_language = i;
break;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/config_emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void config_setLanguage(const char *lang) {
if (lang == NULL) {
return;
}
for (uint8_t i = 0; i < langs_len; i++) {
for (uint8_t i = 0; i < I18N_LANGUAGE_ITEMS; i++) {
if (strcmp(lang, i18n_lang_keys[i]) == 0) {
ui_language = i;
storage_set(KEY_LANGUAGE, lang, strnlen(lang, MAX_LANGUAGE_LEN));
Expand Down Expand Up @@ -931,7 +931,7 @@ bool config_getLabel(char *dest, uint16_t dest_size) {

bool config_getLanguage(char *dest, uint16_t dest_size) {
if (sectrue == config_get_string(KEY_LANGUAGE, dest, dest_size)) {
for (uint8_t i = 0; i < langs_len; i++) {
for (uint8_t i = 0; i < I18N_LANGUAGE_ITEMS; i++) {
if (strcmp(dest, i18n_lang_keys[i]) == 0) {
ui_language = i;
break;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_nostr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void fsm_msgNostrGetPublicKey(const NostrGetPublicKey *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[32] = {0};
strcat(desc, "Nostr ");
strcat(desc, "Public Key");
strcat(desc, _(T__CHAIN_STR_PUBLIC_KEY));
bracket_replace(desc, "Nostr ");
if (!fsm_layoutAddress(resp->npub, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
22 changes: 3 additions & 19 deletions legacy/firmware/gettext.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,10 @@ extern uint8_t ui_language;
char *gettext(const char *msgid) { return (char *)msgid; }

char *gettextX(int msgid) {
switch (ui_language) {
case 1:
return (char *)languages_zh_cn[msgid];
case 2:
return (char *)languages_zh_tw[msgid];
case 3:
return (char *)languages_ja[msgid];
case 4:
return (char *)languages_es[msgid];
case 5:
return (char *)languages_pt_br[msgid];
case 6:
return (char *)languages_de[msgid];
case 7:
return (char *)languages_ko_kr[msgid];
default:
break;
if (ui_language >= I18N_LANGUAGE_ITEMS) {
return (char *)languages_en[msgid];
}

return (char *)languages_en[msgid];
return (char *)languages_table[ui_language][msgid];
}

extern bool is_valid_ascii(const uint8_t *data, uint32_t size);
Expand Down
40 changes: 34 additions & 6 deletions legacy/firmware/i18n/i18n.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#include "i18n.h"

uint8_t langs_len = 8;

// clang-format off
const char* const i18n_lang_keys[] = {"en", "zh_CN", "zh_TW", "ja", "es", "pt", "de", "ko_KR"};
const char* const i18n_langs[] = {"English", "中文 (简体)", "中文 (繁體)", "日本語", "Español", "Português", "Deutsch", "한국어"};
// clang-format on

const char *const i18n_lang_keys[] = {
"en",
"zh_CN",
"zh_TW",
"ja",
"es",
"pt",
"de",
"ko_KR",
};

const char *const i18n_langs[] = {
"English",
"中文 (简体)",
"中文 (繁體)",
"日本語",
"Español",
"Português",
"Deutsch",
"한국어",
};

#include "locales/de.inc"
#include "locales/en.inc"
Expand All @@ -16,4 +33,15 @@ const char* const i18n_langs[] = {"English", "中文 (简体)", "中文 (繁體)
#include "locales/zh_cn.inc"
#include "locales/zh_tw.inc"

int I18N_LANGUAGE_ITEMS = sizeof(languages_en) / sizeof(languages_en[0]);
const char *const *const languages_table[] = {
languages_en,
languages_zh_cn,
languages_zh_tw,
languages_ja,
languages_es,
languages_pt_br,
languages_de,
languages_ko_kr,
};

// clang-format on
19 changes: 17 additions & 2 deletions legacy/firmware/i18n/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@
#include <stdio.h>
#include "keys.h"

#define I18N_ITEMS_COUNT 383
#define I18N_LANGUAGE_ITEMS 8

typedef enum {
I18N_LANG_EN = 0,
I18N_LANG_ZH_CN = 1,
I18N_LANG_ZH_TW = 2,
I18N_LANG_JA = 3,
I18N_LANG_ES = 4,
I18N_LANG_PT_BR = 5,
I18N_LANG_DE = 6,
I18N_LANG_KO_KR = 7,
} i18n_lang_t;

extern const char *const i18n_lang_keys[];
extern const char *const i18n_langs[];
extern uint8_t langs_len;
extern int I18N_LANGUAGE_ITEMS;

extern const char *const languages_en[];
extern const char *const languages_zh_cn[];
Expand All @@ -18,4 +30,7 @@ extern const char *const languages_es[];
extern const char *const languages_pt_br[];
extern const char *const languages_de[];
extern const char *const languages_ko_kr[];

extern const char *const *const languages_table[];

#endif
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
#define T__SWITCH_INPUT_BRACKET_NUMBER 141
// Switch Input (Symbol)
#define T__SWITCH_INPUT_BRACKET_SYMBOL 142
// Use This Passphrase?
// Confirm Passphrase
#define T__USE_THIS_PASSPHRASE_QUES 143
// Access Hidden Wallet
#define T__ACCESS_HIDDEN_WALLET 144
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/de.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_de[] = {
"Eingabe wechseln (Großbuchstaben)",
"Schalteingang (Nummer)",
"Eingabe wechseln (Symbol)",
"Passphrase verwenden?",
"Passphrase bestätigen",
"Hidden Wallet öffnen",
"Der nächste Bildschirm zeigt die eingegebene Passphrase an.",
"Bluetooth-Kopplung",
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/en.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_en[] = {
"Switch Input (Uppercase)",
"Switch Input (Number)",
"Switch Input (Symbol)",
"Use This Passphrase?",
"Confirm Passphrase",
"Access Hidden Wallet",
"Next screen will show the entered Passphrase.",
"Bluetooth Pair",
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/es.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_es[] = {
"Cambiar Entrada (Mayús.)",
"Cambiar Entrada (Número)",
"Cambiar Entrada (Símbolo)",
"¿Usar este passphrase?",
"Confirmar Passphrase",
"Acceder a Billetera Oculta",
"La siguiente pantalla mostrará la Passphrase ingresada.",
"Emparejar Bluetooth",
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/ja.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_ja[] = {
"入力切替 (大文字)",
"入力切替(数値)",
"入力切替 (シンボル)",
"Passphrase 使いますか?",
"パスフレーズを確認",
"ビュー 隠しウォレット",
"次の画面で入力された Passphrase を表示します。",
"Bluetooth ペア",
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/ko_kr.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_ko_kr[] = {
"입력 전환(대문자)",
"입력 전환(숫자)",
"입력 전환(기호)",
"이 Passphrase를 사용하시겠습니까?",
"Passphrase 확인",
"숨겨진 지갑에 접근",
"다음 화면에 입력한 Passphrase가 표시됩니다.",
"블루투스 페어링",
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/pt_br.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_pt_br[] = {
"Trocar Entrada (Maiúsc.)",
"Trocar Entrada (Número)",
"Trocar Entrada (Símbolo)",
"Usar esta Passphrase?",
"Confirmar Passphrase",
"Acessar Carteira Hidden",
"A próxima tela mostrará a Passphrase inserida",
"Pareamento Bluetooth",
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/i18n/locales/zh_cn.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_zh_cn[] = {
"切换输入法(大写字母)",
"切换输入法(数字)",
"切换输入法(符号)",
"使用此 Passphrase",
"确认 Passphrase",
"访问隐藏钱包",
"接下来,屏幕中将展示您输入的 Passphrase。",
"蓝牙配对",
Expand Down Expand Up @@ -258,7 +258,7 @@ const char *const languages_zh_cn[] = {
"备注:",
"批量发送:",
"在输入 PIN页,点击「 」键\n数字减 1,点击「 」键数字\n加 1。",
"在输入 PIN 页,点击「 」键\n数字加 1,点击「 键数字\n减 1。",
"在输入 PIN 页,点击「 」键\n数字加 1,点击「 键数字\n减 1。",
"更新交易",
"交易 ID:",
"新的交易费:",
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/i18n/locales/zh_tw.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const char *const languages_zh_tw[] = {
"切換輸入法(大寫字母)",
"切換輸入法(數字)",
"切換輸入法(符號)",
"使用此 Passphrase",
"確認 Passphrase",
"取用隱藏錢包",
"接下來,螢幕中將展示您輸入的 Passphrase。",
"藍牙配對",
Expand Down
67 changes: 29 additions & 38 deletions legacy/firmware/layout2.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,14 @@ void layout_language_set(uint8_t key) {
}
layoutItemsSelectAdapterEx(
NULL, NULL, NULL, &bmp_bottom_right_arrow, NULL, NULL, index + 1,
langs_len, "Select Language", i18n_langs[index], i18n_langs[index], NULL,
NULL, index > 0 ? i18n_langs[index - 1] : NULL,
I18N_LANGUAGE_ITEMS, "Select Language", i18n_langs[index],
i18n_langs[index], NULL, NULL, index > 0 ? i18n_langs[index - 1] : NULL,
index > 1 ? i18n_langs[index - 2] : NULL,
index > 2 ? i18n_langs[index - 3] : NULL,
index < langs_len - 1 ? i18n_langs[index + 1] : NULL,
index < langs_len - 2 ? i18n_langs[index + 2] : NULL,
index < langs_len - 3 ? i18n_langs[index + 3] : NULL, true, false);
index < I18N_LANGUAGE_ITEMS - 1 ? i18n_langs[index + 1] : NULL,
index < I18N_LANGUAGE_ITEMS - 2 ? i18n_langs[index + 2] : NULL,
index < I18N_LANGUAGE_ITEMS - 3 ? i18n_langs[index + 3] : NULL, true,
false);

switch (key) {
case KEY_UP:
Expand All @@ -481,7 +482,7 @@ void layout_language_set(uint8_t key) {
}
break;
case KEY_DOWN:
if (index < langs_len - 1) {
if (index < I18N_LANGUAGE_ITEMS - 1) {
index++;
}
break;
Expand Down Expand Up @@ -2388,18 +2389,7 @@ static uint8_t layoutPagination(char *title, char *content) {
}

void layoutTxConfirmPage(const char *data) {
char line[64] = {0};
int rows = countlines((char *)data);
int p1 = line_index((char *)data, 1);
int p2 = line_index((char *)data, 2);
memcpy(line, data, p1);
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 13 + 8, line, FONT_STANDARD);
memcpy(line, data + p1 + 1, p2 - p1);
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 13 + 10 + 8, line, FONT_STANDARD);
if (rows > 2) {
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 13 + 20 + 8, data + p2 + 1,
FONT_STANDARD);
}
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 13 + 8, data, FONT_STANDARD);
}

bool layoutConfirmSafetyChecks(SafetyCheckLevel safety_ckeck_level,
Expand Down Expand Up @@ -3647,53 +3637,54 @@ bool layoutInputDirection(int direction) {
_(C__WHEN_ENTERING_PIN_CLICK_THE_UP_BTN_TO_DECREASE_AND_CLICK_THE_DOWN_BTN_TO_INCREASE));
}
switch (ui_language) {
case 0:
case I18N_LANG_EN:
if (direction) {
oledDrawBitmap(42, 22, &bmp_icon_up);
oledDrawBitmap(42, 21, &bmp_icon_up);
oledDrawBitmap(101, 30, &bmp_icon_down);
} else {
oledDrawBitmap(42, 22, &bmp_icon_up);
oledDrawBitmap(11, 40, &bmp_icon_down);
oledDrawBitmap(42, 21, &bmp_icon_up);
oledDrawBitmap(10, 39, &bmp_icon_down);
}
break;
case 1:
oledDrawBitmap(91, 17, &bmp_icon_up);
oledDrawBitmap(71, 28, &bmp_icon_down);
case I18N_LANG_ZH_CN:
case I18N_LANG_ZH_TW:
oledDrawBitmap(92, 17, &bmp_icon_up);
oledDrawBitmap(72, 27, &bmp_icon_down);
break;
case 2:
oledDrawBitmap(95, 17, &bmp_icon_up);
oledDrawBitmap(75, 28, &bmp_icon_down);
break;
case 3:
case I18N_LANG_JA:
if (direction) {
oledDrawBitmap(11, 22, &bmp_icon_up);
oledDrawBitmap(17, 22, &bmp_icon_up);
oledDrawBitmap(50, 32, &bmp_icon_down);
} else {
oledDrawBitmap(12, 22, &bmp_icon_up);
oledDrawBitmap(63, 32, &bmp_icon_down);
oledDrawBitmap(18, 22, &bmp_icon_up);
oledDrawBitmap(62, 32, &bmp_icon_down);
}
break;
case 4:
case I18N_LANG_ES:
oledDrawBitmap(65, 23, &bmp_icon_up);
oledDrawBitmap(6, 42, &bmp_icon_down);
oledDrawBitmap(5, 42, &bmp_icon_down);
break;
case 5:
case I18N_LANG_PT_BR:
oledDrawBitmap(36, 23, &bmp_icon_up);
if (direction) {
oledDrawBitmap(70, 32, &bmp_icon_down);
} else {
oledDrawBitmap(66, 32, &bmp_icon_down);
}
break;
case 6:
case I18N_LANG_DE:
if (direction) {
oledDrawBitmap(71, 17, &bmp_icon_up);
oledDrawBitmap(71, 28, &bmp_icon_down);
oledDrawBitmap(71, 27, &bmp_icon_down);
} else {
oledDrawBitmap(23, 22, &bmp_icon_down);
oledDrawBitmap(103, 32, &bmp_icon_up);
}
break;
case I18N_LANG_KO_KR:
oledDrawBitmap(83, 16, &bmp_icon_up);
oledDrawBitmap(105, 26, &bmp_icon_down);
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/menu_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static const char *_gettext(char *en_str) {
if (!is_valid_ascii((uint8_t *)en_str, len)) {
return en_str;
}
for (int i = 0; i < I18N_LANGUAGE_ITEMS; i++) {
for (int i = 0; i < I18N_ITEMS_COUNT; i++) {
if ((0 == strncmp(en_str, languages_en[i], len)) &&
(len == strlen(languages_en[i]))) {
msgid = i;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/trezor.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ int main(void) {

config_init();
menu_default();
font_init();
layoutHome();
usbInit();
font_init();

#if EMULATOR
system_millis_lock_start = timer_ms();
Expand Down
Loading
Loading