forked from hd-zero/hdzero-goggle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set the main menu item name to Chinese.
- Loading branch information
Showing
4 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "language.h" | ||
|
||
lang_e LANGUAGE = lang_simplified_chinese; | ||
|
||
translate_t simplified_chinese[] = { | ||
{"Scan Now", "扫频"}, | ||
{"Source", "信号源"}, | ||
{"Image Setting", "图像设置"}, | ||
{"OSD", "OSD"}, | ||
{"Power", "电源"}, | ||
{"Fans", "风扇"}, | ||
{"Record Option", "录像设置"}, | ||
{"Auto Scan", "自动扫频"}, | ||
{"ELRS", "ELRS"}, | ||
{"WiFi Module", "WiFi模块"}, | ||
{"Head Tracker", "头部追踪"}, | ||
{"Playback", "录像回放"}, | ||
{"Storage", "存储"}, | ||
{"Firmware ", "固件"}, | ||
{"Focus Chart", "焦点图"}, | ||
{"Clock", "时间"}, | ||
{"Input", "按键"}, | ||
{"Go Sleep!", "睡眠"}, | ||
}; | ||
|
||
char *translate_string(const char *str, lang_e lang) { | ||
int i; | ||
int string_num = sizeof(simplified_chinese) / sizeof(translate_t); | ||
|
||
if (lang == 0) | ||
return (char *)str; | ||
else { | ||
for (i = 0; i < string_num; i++) { | ||
if (strcmp(str, simplified_chinese[i].in_english) == 0) | ||
return simplified_chinese[i].translate; | ||
} | ||
return (char *)str; | ||
} | ||
} | ||
|
||
void lv_label_set_text_lang(lv_obj_t *obj, const char *text, lang_e lang) { | ||
char *text_lang = _str(text, lang); | ||
lv_label_set_text(obj, text_lang); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef _LANGUAGE_H_ | ||
#define _LANGUAGE_H_ | ||
|
||
#include <lvgl/lvgl.h> | ||
|
||
typedef enum { | ||
lang_english = 0, | ||
lang_simplified_chinese = 1, | ||
} lang_e; | ||
|
||
typedef struct { | ||
char *in_english; | ||
char *translate; | ||
} translate_t; | ||
|
||
char *translate_string(const char *str, lang_e lang); | ||
|
||
#define _str(string, lang) translate_string(string, lang) | ||
|
||
void lv_label_set_text_lang(lv_obj_t *obj, const char *text, lang_e lang); | ||
|
||
extern lang_e LANGUAGE; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters