Full multilingual support!

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@640 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-08-04 20:25:10 +00:00
parent 7f3ad99e51
commit 058656de50
13 changed files with 341 additions and 219 deletions

View file

@ -110,15 +110,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
if (*cmdline == '\"') seekchar = *cmdline++;
while (*cmdline && *cmdline != seekchar) if (*cmdline) cmdline++;
if (*cmdline) cmdline++;
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
if (*cmdline) cmdline=CharNext(cmdline);
realcmds=cmdline;
do
{
#ifdef NSIS_CONFIG_CRC_SUPPORT
#endif//NSIS_CONFIG_CRC_SUPPORT
while (*cmdline == ' ') if (*cmdline) cmdline++;
while (*cmdline == ' ') cmdline=CharNext(cmdline);
if (cmdline[0] != '/') break;
cmdline++;
#if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT)
@ -147,7 +147,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
lstrcpy(state_install_directory,cmdline+2);
cmdline+=lstrlen(cmdline);
}
else while (*cmdline && *cmdline != ' ') if (*cmdline) cmdline++;
else while (*cmdline && *cmdline != ' ') cmdline=CharNext(cmdline);
}
while (*cmdline);

View file

@ -42,7 +42,9 @@
installer_strings *install_strings_tables;
common_strings *common_strings_tables;
uninstall_strings *uninstall_strings_tables;
int current_lang;
installer_strings *cur_install_strings_table;
common_strings *cur_common_strings_table;
uninstall_strings *cur_uninstall_strings_table;
int g_quit_flag; // set when Quit has been called (meaning bail out ASAP)
@ -211,7 +213,6 @@ static void CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) {
int ui_doinstall(void)
{
int size;
g_autoclose=g_inst_cmnheader->misc_flags&1;
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
if (!g_is_uninstaller)
@ -234,9 +235,9 @@ int ui_doinstall(void)
char *e;
if (p[0]=='\"')
{
char *p2=*p?p+1:p;
char *p2=CharNext(p);
p=p2;
while (*p2 && *p2 != '\"') if (*p2) p2++;
while (*p2 && *p2 != '\"') p2=CharNext(p2);
*p2=0;
}
// p is the path now, check for .exe extension
@ -266,22 +267,6 @@ int ui_doinstall(void)
process_string_fromtab(state_install_directory,g_inst_header->install_directory_ptr);
}
// Added by Amir Szekely 3rd August 2002
// Multilingual support
size=g_inst_header->common.str_tables_num*sizeof(common_strings);
common_strings_tables=(common_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->common.str_tables,(char*)common_strings_tables,size);
if (!g_is_uninstaller) {
size=g_inst_header->str_tables_num*sizeof(installer_strings);
install_strings_tables=(installer_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)install_strings_tables,size);
}
else {
size=g_inst_header->str_tables_num*sizeof(uninstall_strings);
uninstall_strings_tables=(uninstall_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)uninstall_strings_tables,size);
}
#ifdef NSIS_CONFIG_LOG
if (g_inst_cmnheader->silent_install==2)
{
@ -291,6 +276,33 @@ int ui_doinstall(void)
#endif
}
{
// Added by Amir Szekely 3rd August 2002
// Multilingual support
LANGID user_lang=GetUserDefaultLangID();
int size=g_inst_header->common.str_tables_num*sizeof(common_strings);
cur_common_strings_table=common_strings_tables=(common_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->common.str_tables,(char*)common_strings_tables,size);
if (!g_is_uninstaller) {
size=g_inst_header->str_tables_num*sizeof(installer_strings);
cur_install_strings_table=install_strings_tables=(installer_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)install_strings_tables,size);
}
else {
size=g_inst_header->str_tables_num*sizeof(uninstall_strings);
cur_uninstall_strings_table=uninstall_strings_tables=(uninstall_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)uninstall_strings_tables,size);
}
for (size=0; size<g_inst_header->str_tables_num; size++) {
if (user_lang == common_strings_tables[size].lang_id) {
cur_install_strings_table = &install_strings_tables[size];
cur_common_strings_table = &common_strings_tables[size];
cur_uninstall_strings_table = &uninstall_strings_tables[size];
break;
}
}
}
process_string_fromtab(g_caption,COMMON_STR(caption));
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT

View file

@ -15,12 +15,6 @@
HWND g_SectionHack;
#endif
// Added by Amir Szekely 3rd August 2002
extern installer_strings *install_strings_tables;
extern common_strings *common_strings_tables;
extern uninstall_strings *uninstall_strings_tables;
extern int current_lang;
#ifdef NSIS_SUPPORT_STACK
typedef struct _stack_t {
struct _stack_t *next;
@ -399,7 +393,7 @@ static int ExecuteEntry(entry *entries, int pos)
lstrcpy(buf3,g_usrvars[0]);//save $0
lstrcpy(g_usrvars[0],buf);
process_string(buf2,LANG_FILEERR);
process_string_fromtab(buf2,COMMON_STR(fileerrtext));
lstrcpy(g_usrvars[0],buf3); // restore $0
switch (MessageBox(g_hwnd,buf2,g_caption,MB_ABORTRETRYIGNORE|MB_ICONSTOP))
@ -1344,6 +1338,7 @@ static int ExecuteEntry(entry *entries, int pos)
case EW_LOG:
if (parms[0])
{
if (!g_log_file && parms[1]) build_g_logfile();
log_printf2("settings logging to %d",parms[1]);
log_dolog=parms[1];
log_printf2("logging set to %d",parms[1]);

View file

@ -400,7 +400,7 @@ int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut);
int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len);
// $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value.
#define VAR_CODES_START (256 - 35)
#define VAR_CODES_START (256 - 36)
#endif //_FILEFORM_H_

View file

@ -27,7 +27,7 @@
// Please note that all of these define the offset not the string itself.
// To get the string it self use process_string_fromtab or GetStringFromStringTab.
#define INSTALL_STR(x) (install_strings_tables[current_lang].x)
#define INSTALL_STR(x) (cur_install_strings_table->x)
// Installer specific strings
#define LANG_BTN_BACK GetStringFromStringTab(INSTALL_STR(backbutton))
@ -45,14 +45,14 @@
#define LANG_LICENSE_DATA GetStringFromStringTab(INSTALL_STR(licensedata))
#define LANG_BTN_LICENSE GetStringFromStringTab(INSTALL_STR(licensebutton))
#define UNINSTALL_STR(x) (uninstall_strings_tables[current_lang].x)
#define UNINSTALL_STR(x) (cur_uninstall_strings_table->x)
// Uninstall specific strings
#define LANG_BTN_UNINST GetStringFromStringTab(UNINSTALL_STR(uninstbutton))
#define LANG_UNINST_TEXT GetStringFromStringTab(UNINSTALL_STR(uninstalltext))
#define LANG_UNINST_SUBTEXT GetStringFromStringTab(UNINSTALL_STR(uninstalltext2))
#define COMMON_STR(x) (common_strings_tables[current_lang].x)
#define COMMON_STR(x) (cur_common_strings_table->x)
// Common strings
#define LANG_BRANDING GetStringFromStringTab(COMMON_STR(branding))

View file

@ -1,6 +1,11 @@
#ifndef _UI_H_
#define _UI_H_
// Added by Amir Szekely 3rd August 2002
extern installer_strings *cur_install_strings_table;
extern common_strings *cur_common_strings_table;
extern uninstall_strings *cur_uninstall_strings_table;
int ui_doinstall(void);
void update_status_text(const char *text1, const char *text2);
extern int ui_st_updateflag;

View file

@ -61,7 +61,7 @@ char *scanendslash(const char *str)
int validpathspec(char *ubuf)
{
return ((ubuf[0]=='\\' && ubuf[1]=='\\') || (ubuf[0] && *(ubuf+1)==':'));
return ((ubuf[0]=='\\' && ubuf[1]=='\\') || (ubuf[0] && *CharNext(ubuf)==':'));
}
int is_valid_instpath(char *s)
@ -75,7 +75,7 @@ int is_valid_instpath(char *s)
while (*s)
{
if (*s == '\\') ivp++;
if (*s) s++;
s=CharNext(s);
}
ivp/=5-req;
}
@ -83,13 +83,13 @@ int is_valid_instpath(char *s)
{
if (*s)
{
if (*s) s++;
s=CharNext(s);
if (*s == ':')
{
if (*s) s++;
s=CharNext(s);
if (*s == '\\')
{
if (*s) s++;
s=CharNext(s);
if (req || (*s && *s != '\\')) ivp++;
}
}
@ -237,24 +237,24 @@ void recursive_create_directory(char *directory)
char *tp;
char *p;
p=directory;
while (*p == ' ') if (*p) p++;
while (*p == ' ') p=CharNext(p);
if (!*p) return;
tp=*p?p+1:p;
tp=CharNext(p);
if (*tp == ':' && tp[1] == '\\') p=tp+2;
else if (p[0] == '\\' && p[1] == '\\')
{
int x;
for (x = 0; x < 2; x ++)
{
while (*p != '\\' && *p) if (*p) p++; // skip host then share
if (*p) if (*p) p++;
while (*p != '\\' && *p) p=CharNext(p); // skip host then share
if (*p) p=CharNext(p);
}
}
else return;
while (*p)
{
while (*p != '\\' && *p) if (*p) p++;
while (*p != '\\' && *p) CharNext(p);
if (!*p) CreateDirectory(directory,NULL);
else
{
@ -452,15 +452,19 @@ void process_string(char *out, const char *in)
GetSystemDirectory(out, NSIS_MAX_STRLEN);
break;
#if VAR_CODES_START + 33 >= 255
case VAR_CODES_START + 34: // LANGUAGE
wsprintf(out, "%u", cur_common_strings_table->lang_id);
break;
#if VAR_CODES_START + 34 >= 255
#error "Too many variables! Extend VAR_CODES_START!"
#endif
} // switch
// remove trailing slash
while (*out && *(out+1)) out++;
while (*out && *CharNext(out)) out++;
if (nVarIdx > 21+VAR_CODES_START && *out == '\\') // only if not $0 to $R9, $CMDLINE, or $HWNDPARENT
*out = 0;
if (*out) out++;
out=CharNext(out);
} // >= VAR_CODES_START
} // while
*out = 0;