• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revisão8569 (tree)
Hora2020-02-27 01:27:42
Autorzmatsuo

Mensagem de Log

ドロップダウンリストなどを多言語化するための SetI18nList() を追加

- addsetting.cpp のリスト初期化に使用

Mudança Sumário

Diff

--- trunk/teraterm/common/i18n.h (revision 8568)
+++ trunk/teraterm/common/i18n.h (revision 8569)
@@ -46,9 +46,13 @@
4646 const char *key;
4747 } DlgTextInfo;
4848
49+typedef struct {
50+ const char *key; // NULLの場合は常にdefault_text が使用される
51+ const wchar_t *default_text; // key == NULL && default_text == NULLの場合終端
52+} I18nTextInfo;
53+
4954 DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def, const char *iniFile);
5055 DllExport void WINAPI GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile);
51-void GetI18nStrU8(const char* section, const char* key, char* buf, int buf_len, const char* def, const char* iniFile);
5256 DllExport int WINAPI GetI18nLogfont(const char *section, const char *key, PLOGFONTA logfont, int ppi, const char *iniFile);
5357 DllExport int WINAPI SetI18nDlgStrs(const char *section, HWND hDlgWnd,
5458 const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile);
@@ -55,6 +59,11 @@
5559 DllExport void WINAPI SetI18nMenuStrs(const char *section, HMENU hMenu,
5660 const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile);
5761
62+// i18n_static.c
63+void GetI18nStrU8(const char *section, const char *key, char *buf, int buf_len, const char *def, const char *iniFile);
64+void SetI18nList(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextInfo *infos, size_t infoCount,
65+ const char *UILanguageFile, int nsel);
66+
5867 #ifdef __cplusplus
5968 }
6069 #endif
--- trunk/teraterm/common/i18n_static.c (revision 8568)
+++ trunk/teraterm/common/i18n_static.c (revision 8569)
@@ -29,6 +29,7 @@
2929 #include "i18n.h"
3030 #include "codeconv.h"
3131 #include "compat_win.h"
32+#include "layer_for_unicode.h"
3233
3334 #include <assert.h>
3435
@@ -60,4 +61,62 @@
6061 }
6162 }
6263
64+/**
65+ * リストを設定する
66+ * SetDropDownList() の他言語版
67+ *
68+ * @param[in] section UILanguageFile のセクション名
69+ * @param[in] hDlg ダイアログ
70+ * @param[in] nIDDlgItem id
71+ * @param[in] I18nTextInfo テキスト情報
72+ * @param[in] infoCount テキスト情報数
73+ * @param[in] UILanguageFile lng file
74+ * @param[in] nsel CB_SETCURSEL の引数と同じ
75+ * -1 未選択
76+ * 0〜 選択項目
77+ */
78+void SetI18nList(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextInfo *infos, size_t infoCount,
79+ const char *UILanguageFile, int nsel)
80+{
81+ UINT ADDSTRING;
82+ UINT SETCURSEL;
83+ int i;
84+ char ClassName[32];
85+ int r = GetClassNameA(GetDlgItem(hDlg, nIDDlgItem), ClassName, _countof(ClassName));
86+ assert(r != 0);
87+ (void)r;
88+
89+ if (strcmp(ClassName, "ListBox") == 0) {
90+ ADDSTRING = LB_ADDSTRING;
91+ SETCURSEL = LB_SETCURSEL;
92+ }
93+ else {
94+ // "ComboBox"
95+ ADDSTRING = CB_ADDSTRING;
96+ SETCURSEL = CB_SETCURSEL;
97+ }
98+
99+ if (infoCount == 0) {
100+ // 0 のときは、終端を探す
101+ i = 0;
102+ while (infos[i].key != NULL && infos[i].default_text != NULL) {
103+ i++;
104+ }
105+ infoCount = i;
106+ }
107+
108+ for (i = 0; i < infoCount; i++) {
109+ if (infos->key != NULL) {
110+ wchar_t uimsg[MAX_UIMSG];
111+ GetI18nStrW(section, infos->key, uimsg, _countof(uimsg), infos->default_text, UILanguageFile);
112+ _SendDlgItemMessageW(hDlg, nIDDlgItem, ADDSTRING, 0, (LPARAM)uimsg);
113+ }
114+ else {
115+ _SendDlgItemMessageW(hDlg, nIDDlgItem, ADDSTRING, 0, (LPARAM)infos->default_text);
116+ }
117+ infos++;
118+ }
119+ SendDlgItemMessageA(hDlg, nIDDlgItem, SETCURSEL, nsel, 0);
120+}
121+
63122 /* vim: set ts=4 sw=4 ff=dos : */
--- trunk/teraterm/teraterm/addsetting.cpp (revision 8568)
+++ trunk/teraterm/teraterm/addsetting.cpp (revision 8569)
@@ -40,6 +40,7 @@
4040 #define _CRTDBG_MAP_ALLOC
4141 #include <stdlib.h>
4242 #include <crtdbg.h>
43+#include <assert.h>
4344
4445 #include "teraterm.h"
4546 #include "tttypes.h"
@@ -51,8 +52,8 @@
5152 #include "helpid.h"
5253 #include "addsetting.h"
5354 #include "debug_pp.h"
54-
5555 #include "tipwin.h"
56+#include "i18n.h"
5657
5758 const mouse_cursor_t MouseCursor[] = {
5859 {"ARROW", IDC_ARROW},
@@ -246,31 +247,31 @@
246247 };
247248 SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
248249
249- wchar_t uimsg[MAX_UIMSG];
250- get_lang_msgW("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_OFF", uimsg, _countof(uimsg), L"off", ts.UILanguageFile);
251- SendDlgItemMessageW(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)uimsg);
252- get_lang_msgW("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_OVERWRITE", uimsg, _countof(uimsg), L"overwrite", ts.UILanguageFile);
253- SendDlgItemMessageW(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)uimsg);
254- get_lang_msgW("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_AHEAD", uimsg, _countof(uimsg), L"ahead", ts.UILanguageFile);
255- SendDlgItemMessageW(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)uimsg);
256- get_lang_msgW("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_LAST", uimsg, _countof(uimsg), L"last", ts.UILanguageFile);
257- SendDlgItemMessageW(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)uimsg);
250+ const static I18nTextInfo accept_title_changing[] = {
251+ { "DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_OFF", L"off" },
252+ { "DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_OVERWRITE", L"overwrite" },
253+ { "DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_AHEAD", L"ahead" },
254+ { "DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_LAST", L"last" },
255+ };
256+ SetI18nList("Tera Term", m_hWnd, IDC_ACCEPT_TITLE_CHANGING, accept_title_changing, _countof(accept_title_changing),
257+ ts.UILanguageFile, 0);
258258
259- get_lang_msgW("DLG_TAB_SEQUENCE_TITLE_REPORT_IGNORE", uimsg, _countof(uimsg), L"ignore", ts.UILanguageFile);
260- SendDlgItemMessageW(IDC_TITLE_REPORT, CB_ADDSTRING, 0, (LPARAM)uimsg);
261- get_lang_msgW("DLG_TAB_SEQUENCE_TITLE_REPORT_ACCEPT", uimsg, _countof(uimsg), L"accept", ts.UILanguageFile);
262- SendDlgItemMessageW(IDC_TITLE_REPORT, CB_ADDSTRING, 0, (LPARAM)uimsg);
263- get_lang_msgW("DLG_TAB_SEQUENCE_TITLE_REPORT_EMPTY", uimsg, _countof(uimsg), L"empty", ts.UILanguageFile);
264- SendDlgItemMessageW(IDC_TITLE_REPORT, CB_ADDSTRING, 0, (LPARAM)uimsg);
259+ const static I18nTextInfo sequence_title_report[] = {
260+ { "DLG_TAB_SEQUENCE_TITLE_REPORT_IGNORE", L"ignore" },
261+ { "DLG_TAB_SEQUENCE_TITLE_REPORT_ACCEPT", L"accept" },
262+ { "DLG_TAB_SEQUENCE_TITLE_REPORT_EMPTY", L"empty" },
263+ };
264+ SetI18nList("Tera Term", m_hWnd, IDC_TITLE_REPORT, sequence_title_report, _countof(sequence_title_report),
265+ ts.UILanguageFile, 0);
265266
266- get_lang_msgW("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_OFF", uimsg, _countof(uimsg), L"off", ts.UILanguageFile);
267- SendDlgItemMessageW(IDC_CLIPBOARD_ACCESS, CB_ADDSTRING, 0, (LPARAM)uimsg);
268- get_lang_msgW("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_WRITE", uimsg, _countof(uimsg), L"write only", ts.UILanguageFile);
269- SendDlgItemMessageW(IDC_CLIPBOARD_ACCESS, CB_ADDSTRING, 0, (LPARAM)uimsg);
270- get_lang_msgW("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_READ", uimsg, _countof(uimsg), L"read only", ts.UILanguageFile);
271- SendDlgItemMessageW(IDC_CLIPBOARD_ACCESS, CB_ADDSTRING, 0, (LPARAM)uimsg);
272- get_lang_msgW("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_ON", uimsg, _countof(uimsg), L"read/write", ts.UILanguageFile);
273- SendDlgItemMessageW(IDC_CLIPBOARD_ACCESS, CB_ADDSTRING, 0, (LPARAM)uimsg);
267+ const static I18nTextInfo sequence_clipboard_access[] = {
268+ { "DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_OFF", L"off" },
269+ { "DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_WRITE", L"write only" },
270+ { "DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_READ", L"read only" },
271+ { "DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_ON", L"read/write" },
272+ };
273+ SetI18nList("Tera Term", m_hWnd, IDC_CLIPBOARD_ACCESS, sequence_clipboard_access,
274+ _countof(sequence_clipboard_access), ts.UILanguageFile, 0);
274275
275276 // (1)IDC_ACCEPT_MOUSE_EVENT_TRACKING
276277 SetCheck(IDC_ACCEPT_MOUSE_EVENT_TRACKING, ts.MouseEventTracking);
@@ -666,19 +667,14 @@
666667 };
667668 SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
668669
669- wchar_t uimsg[MAX_UIMSG];
670- get_lang_msgW("DLG_TAB_VISUAL_FONT_QUALITY_DEFAULT",
671- uimsg, _countof(uimsg), L"Default", ts.UILanguageFile);
672- SendDlgItemMessageW(IDC_FONT_QUALITY, CB_ADDSTRING, 0, (LPARAM)uimsg);
673- get_lang_msgW("DLG_TAB_VISUAL_FONT_QUALITY_NONANTIALIASED",
674- uimsg, _countof(uimsg), L"Non-Antialiased", ts.UILanguageFile);
675- SendDlgItemMessageW(IDC_FONT_QUALITY, CB_ADDSTRING, 0, (LPARAM)uimsg);
676- get_lang_msgW("DLG_TAB_VISUAL_FONT_QUALITY_ANTIALIASED",
677- uimsg, _countof(uimsg), L"Antialiased", ts.UILanguageFile);
678- SendDlgItemMessageW(IDC_FONT_QUALITY, CB_ADDSTRING, 0, (LPARAM)uimsg);
679- get_lang_msgW("DLG_TAB_VISUAL_FONT_QUALITY_CLEARTYPE",
680- uimsg, _countof(uimsg), L"ClearType", ts.UILanguageFile);
681- SendDlgItemMessageW(IDC_FONT_QUALITY, CB_ADDSTRING, 0, (LPARAM)uimsg);
670+ const static I18nTextInfo visual_font_quality[] = {
671+ { "DLG_TAB_VISUAL_FONT_QUALITY_DEFAULT", L"Default" },
672+ { "DLG_TAB_VISUAL_FONT_QUALITY_NONANTIALIASED", L"Non-Antialiased" },
673+ { "DLG_TAB_VISUAL_FONT_QUALITY_ANTIALIASED", L"Antialiased" },
674+ { "DLG_TAB_VISUAL_FONT_QUALITY_CLEARTYPE", L"ClearType" },
675+ };
676+ SetI18nList("Tera Term", m_hWnd, IDC_FONT_QUALITY, visual_font_quality, _countof(visual_font_quality),
677+ ts.UILanguageFile, 0);
682678
683679 // (1)AlphaBlend
684680
@@ -1298,17 +1294,15 @@
12981294 };
12991295 SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
13001296
1301- TCHAR UIMsg[MAX_UIMSG];
1302- get_lang_msgT("DLG_FOPT_TIMESTAMP_LOCAL", UIMsg, _countof(UIMsg), _T("Local Time"), ts.UILanguageFile);
1303- SendDlgItemMessage(IDC_OPT_TIMESTAMP_TYPE, CB_ADDSTRING, 0, (LPARAM)UIMsg);
1304- get_lang_msgT("DLG_FOPT_TIMESTAMP_UTC", UIMsg, _countof(UIMsg), _T("UTC"), ts.UILanguageFile);
1305- SendDlgItemMessage(IDC_OPT_TIMESTAMP_TYPE, CB_ADDSTRING, 0, (LPARAM)UIMsg);
1306- get_lang_msgT("DLG_FOPT_TIMESTAMP_ELAPSED_LOGGING", UIMsg, _countof(UIMsg), _T("Elapsed Time (Logging)"), ts.UILanguageFile);
1307- SendDlgItemMessage(IDC_OPT_TIMESTAMP_TYPE, CB_ADDSTRING, 0, (LPARAM)UIMsg);
1308- get_lang_msgT("DLG_FOPT_TIMESTAMP_ELAPSED_CONNECTION", UIMsg, _countof(UIMsg), _T("Elapsed Time (Connection)"), ts.UILanguageFile);
1309- SendDlgItemMessage(IDC_OPT_TIMESTAMP_TYPE, CB_ADDSTRING, 0, (LPARAM)UIMsg);
1297+ const static I18nTextInfo fopt_timestamp[] = {
1298+ { "DLG_FOPT_TIMESTAMP_LOCAL", L"Local Time" },
1299+ { "DLG_FOPT_TIMESTAMP_UTC", L"UTC" },
1300+ { "DLG_FOPT_TIMESTAMP_ELAPSED_LOGGING", L"Elapsed Time (Logging)" },
1301+ { "DLG_FOPT_TIMESTAMP_ELAPSED_CONNECTION", L"Elapsed Time (Connection)" },
1302+ };
1303+ SetI18nList("Tera Term", m_hWnd, IDC_OPT_TIMESTAMP_TYPE, fopt_timestamp, _countof(fopt_timestamp),
1304+ ts.UILanguageFile, 0);
13101305
1311-
13121306 // Viewlog Editor path (2005.1.29 yutaka)
13131307 SetDlgItemTextA(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor);
13141308
Show on old repository browser