Skip to content

Commit 900306d

Browse files
committed
language enhancement
1 parent 180ed90 commit 900306d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

fw/application/src/i18n/language.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const LanguageData const languageData[LANGUAGE_COUNT] = {
1818
Language currentLanguage = LANGUAGE_ZH_HANS;
1919

2020
const char *getLangString(L_StringID stringID) {
21+
if (stringID >= _L_COUNT) {
22+
return "@@STR@@";
23+
}
24+
if (currentLanguage >= LANGUAGE_COUNT) {
25+
return lang_en_US[stringID];
26+
}
2127
const char *string = languageData[currentLanguage].strings[stringID];
2228
return string && strlen(string) > 0 ? string : lang_en_US[stringID];
2329
}
@@ -47,6 +53,8 @@ const char *getLangDesc(Language lang) {
4753
return "日本語";
4854
} else if (lang == LANGUAGE_PT_PT) {
4955
return "Português(Portugal)";
56+
} else {
57+
return "@@LANG@@";
5058
}
5159
}
5260

fw/application/src/main.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
#include "hal_spi_flash.h"
9494

9595
#include "cache.h"
96-
#include "settings.h"
9796
#include "i18n/language.h"
97+
#include "settings.h"
9898

9999
#define APP_SCHED_MAX_EVENT_SIZE 4 /**< Maximum size of scheduler events. */
100100
#define APP_SCHED_QUEUE_SIZE 16 /**< Maximum number of events in the scheduler queue. */
@@ -104,7 +104,6 @@
104104

105105
#define APP_SHUTDOWN_HANDLER_PRIORITY 1
106106

107-
108107
int8_t g_usb_led_marquee_enable = 0; /** dummy for chameleon */
109108

110109
// #define SPI_FLASH
@@ -166,8 +165,6 @@ static bool shutdown_handler(nrf_pwr_mgmt_evt_t event) {
166165
// save settings
167166
settings_save();
168167

169-
170-
171168
hal_spi_flash_sleep();
172169

173170
err_code = bsp_wakeup_button_enable(BTN_ID_SLEEP);
@@ -260,7 +257,7 @@ int main(void) {
260257
err_code = ntag_emu_init(&default_ntag215);
261258
APP_ERROR_CHECK(err_code);
262259

263-
//cache_clean(); //FOR TESTING
260+
// cache_clean(); //FOR TESTING
264261
check_wakeup_src();
265262

266263
err_code = settings_init();
@@ -277,11 +274,8 @@ int main(void) {
277274

278275
NRF_LOG_DEBUG("init done");
279276

280-
if (p_settings->language >= LANGUAGE_COUNT) {
281-
p_settings->language = LANGUAGE_EN_US;
282-
}
283277
setLanguage(p_settings->language);
284-
278+
285279
mui_t *p_mui = mui();
286280
mui_init(p_mui);
287281

fw/components/chameleon-ultra

0 commit comments

Comments
 (0)