Added user defined multilingual strings. Define using LangString [un.]name lang_id string, use with $(name). Can't be used inside other strings.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1214 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9adf8df382
commit
bb60e32aaa
14 changed files with 325 additions and 255 deletions
|
@ -42,10 +42,10 @@ HICON g_hIcon;
|
|||
static char gDontFookWithFocus = 0;
|
||||
|
||||
// Added by Amir Szekely 3rd August 2002
|
||||
common_strings *common_strings_tables;
|
||||
char *language_tables;
|
||||
common_strings *cur_common_strings_table;
|
||||
char *install_strings_tables; // installer_strings/uninstall_strings depending on installer type
|
||||
char *cur_install_strings_table;
|
||||
char *cur_install_strings_table; // installer_strings/uninstall_strings depending on installer type
|
||||
int *cur_user_strings_table;
|
||||
|
||||
int g_quit_flag; // set when Quit has been called (meaning bail out ASAP)
|
||||
|
||||
|
@ -252,26 +252,32 @@ static void NSISCALL set_language()
|
|||
int i;
|
||||
LANGID lang_mask=~(LANGID)0;
|
||||
LANGID lang=myatoi(state_language);
|
||||
char *language_table=0;
|
||||
|
||||
lang_again:
|
||||
for (i = 0; i < lang_num; i++) {
|
||||
if (!((lang ^ common_strings_tables[i].lang_id) & lang_mask)) {
|
||||
cur_common_strings_table=common_strings_tables+i;
|
||||
language_table=language_tables+i*g_inst_cmnheader->language_table_size;
|
||||
if (!((lang ^ *(LANGID*)language_table) & lang_mask)) {
|
||||
cur_common_strings_table=(common_strings*)(language_table+sizeof(LANGID));
|
||||
cur_install_strings_table=(void*)(cur_common_strings_table+1);
|
||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
if (g_is_uninstaller)
|
||||
(uninstall_strings *)cur_install_strings_table=(uninstall_strings *)install_strings_tables+i;
|
||||
cur_user_strings_table=(int*)((uninstall_strings*)cur_install_strings_table+1);
|
||||
else
|
||||
#endif
|
||||
(installer_strings *)cur_install_strings_table=(installer_strings *)install_strings_tables+i;
|
||||
cur_user_strings_table=(int*)((installer_strings*)cur_install_strings_table+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((i == lang_num) && (lang_mask == ~(LANGID)0)) {
|
||||
lang_mask=0x3ff; // primary lang
|
||||
if (i == lang_num) {
|
||||
if (lang_mask == ~(LANGID)0)
|
||||
lang_mask=0x3ff; // primary lang
|
||||
else // we already tried once and we still don't have a language table
|
||||
lang_mask=0; // first lang
|
||||
goto lang_again;
|
||||
}
|
||||
|
||||
myitoa(state_language, cur_common_strings_table->lang_id);
|
||||
myitoa(state_language, *(LANGID*)language_table);
|
||||
|
||||
SendMessage(m_bgwnd, WM_SETTEXT, 0, (LPARAM)process_string_from_lang(g_caption,LANGID_CAPTION));
|
||||
}
|
||||
|
@ -290,7 +296,7 @@ int NSISCALL ui_doinstall(void)
|
|||
#endif
|
||||
if (!is_valid_instpath(state_install_directory))
|
||||
{
|
||||
if (g_inst_header->install_reg_key_ptr>=0)
|
||||
if (g_inst_header->install_reg_key_ptr)
|
||||
{
|
||||
myRegGetStr((HKEY)g_inst_header->install_reg_rootkey,
|
||||
GetStringFromStringTab(g_inst_header->install_reg_key_ptr),
|
||||
|
@ -347,10 +353,7 @@ int NSISCALL ui_doinstall(void)
|
|||
{
|
||||
extern char *g_db_strtab;
|
||||
lang_num=g_inst_cmnheader->str_tables_num;
|
||||
cur_common_strings_table=common_strings_tables=
|
||||
(common_strings*)(g_db_strtab+g_inst_cmnheader->num_string_bytes);
|
||||
cur_install_strings_table=install_strings_tables=
|
||||
(char*)((unsigned long)common_strings_tables+lang_num*sizeof(common_strings));
|
||||
language_tables=(void*)(g_db_strtab+g_inst_cmnheader->num_string_bytes);
|
||||
|
||||
myitoa(state_language, GetUserDefaultLangID());
|
||||
set_language();
|
||||
|
@ -492,19 +495,19 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
if (g_is_uninstaller)
|
||||
{
|
||||
islp = (LANG_UNINST_TEXT>=0);
|
||||
islp = (LANG_UNINST_TEXT>0);
|
||||
iscp++;
|
||||
}
|
||||
else
|
||||
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
{
|
||||
#ifdef NSIS_CONFIG_LICENSEPAGE
|
||||
islp = (LANG_LICENSE_DATA>=0);
|
||||
islp = (LANG_LICENSE_DATA>0);
|
||||
#endif//NSIS_CONFIG_LICENSEPAGE
|
||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||
iscp = (LANG_COMP_TEXT>=0);
|
||||
iscp = (LANG_COMP_TEXT>0);
|
||||
#endif//NSIS_CONFIG_COMPONENTPAGE
|
||||
ispotentiallydp = (LANG_DIR_TEXT>=0);
|
||||
ispotentiallydp = (LANG_DIR_TEXT>0);
|
||||
if (ispotentiallydp &&
|
||||
!((g_inst_cmnheader->misc_flags&2) &&
|
||||
is_valid_instpath(state_install_directory)
|
||||
|
@ -859,7 +862,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
|
||||
// Added by Amir Szekely 24th July 2002
|
||||
// Allows 'SpaceTexts none'
|
||||
if (LANG_SPACE_REQ >= 0) {
|
||||
if (LANG_SPACE_REQ) {
|
||||
inttosizestr(total,mystrcpy(s,STR(LANG_SPACE_REQ)));
|
||||
SetUITextNT(IDC_SPACEREQUIRED,s);
|
||||
if (available != -1)
|
||||
|
@ -979,14 +982,14 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
|
||||
DeleteObject(hBMcheck1);
|
||||
|
||||
if (g_inst_header->install_types_ptr[0]<0)
|
||||
if (!g_inst_header->install_types_ptr[0])
|
||||
{
|
||||
ShowWindow(hwndCombo1,SW_HIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (m_num_insttypes = 0; m_num_insttypes < NSIS_MAX_INST_TYPES &&
|
||||
g_inst_header->install_types_ptr[m_num_insttypes]>=0; m_num_insttypes ++)
|
||||
g_inst_header->install_types_ptr[m_num_insttypes]; m_num_insttypes ++)
|
||||
{
|
||||
SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetStringFromStringTab(g_inst_header->install_types_ptr[m_num_insttypes]));
|
||||
}
|
||||
|
@ -998,7 +1001,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
|
||||
for (x = 0; x < num_sections; x ++)
|
||||
{
|
||||
if (g_inst_section[x].name_ptr>=0)
|
||||
if (g_inst_section[x].name_ptr)
|
||||
{
|
||||
TVINSERTSTRUCT tv;
|
||||
tv.hParent=Par;
|
||||
|
@ -1038,7 +1041,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
tv.item.pszText++;
|
||||
tv.item.mask|=TVIF_CHILDREN;
|
||||
tv.item.cChildren=1;
|
||||
if (g_inst_section[x].name_ptr>=0 && g_inst_section[x].expand)
|
||||
if (g_inst_section[x].name_ptr && g_inst_section[x].expand)
|
||||
tv.item.state|=TVIS_EXPANDED;
|
||||
Par = hTreeItems[x] = TreeView_InsertItem(hwndTree1,&tv);
|
||||
doLines=1;
|
||||
|
@ -1074,7 +1077,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
int x=wParam;
|
||||
int ns=lParam;
|
||||
|
||||
if (g_inst_section[x].name_ptr>=0 && ns >= 0)
|
||||
if (g_inst_section[x].name_ptr && ns >= 0)
|
||||
{
|
||||
TVITEM tv;
|
||||
tv.hItem=hTreeItems[x];
|
||||
|
@ -1200,7 +1203,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
HTREEITEM *ht=hTreeItems;
|
||||
while (x--)
|
||||
{
|
||||
if (t->name_ptr>=0 && !(t->default_state & DFS_RO))
|
||||
if (t->name_ptr && !(t->default_state & DFS_RO))
|
||||
{
|
||||
TVITEM tv;
|
||||
int l=1;
|
||||
|
@ -1248,7 +1251,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
ShowWindow(GetUIItem(IDC_TEXT2),c);
|
||||
}
|
||||
|
||||
if (LANG_SPACE_REQ >= 0) {
|
||||
if (LANG_SPACE_REQ) {
|
||||
int x,total;
|
||||
char s[128];
|
||||
for (total=x=0; x < num_sections; x ++)
|
||||
|
|
|
@ -569,7 +569,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
char *p=var0;
|
||||
char *buf0=process_string_fromparm_tobuf(0x01);
|
||||
*p=0;
|
||||
if (parm2 < 0 || newlen)
|
||||
if (!parm2 || newlen)
|
||||
{
|
||||
l=mystrlen(buf0);
|
||||
|
||||
|
@ -737,7 +737,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
v=(int)FindWindowEx((HWND)b3,(HWND)b4,buf0[0]?buf0:NULL,buf1[0]?buf1:NULL);
|
||||
}
|
||||
|
||||
if (parm0>=0)
|
||||
if (parm0)
|
||||
myitoa(var0,v);
|
||||
}
|
||||
return 0;
|
||||
|
@ -928,7 +928,13 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
if (funke)
|
||||
{
|
||||
exec_errorflag--;
|
||||
if (parm2<0)
|
||||
if (parm2)
|
||||
{
|
||||
char *buf2=process_string_fromparm_tobuf(0x22);
|
||||
update_status_text(buf2,buf0);
|
||||
funke();
|
||||
}
|
||||
else
|
||||
{
|
||||
void (*func)(HWND,int,char*,void*);
|
||||
func=(void*)funke;
|
||||
|
@ -939,12 +945,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
NULL);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
char *buf2=process_string_fromparm_tobuf(0x22);
|
||||
update_status_text(buf2,buf0);
|
||||
funke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1107,11 +1107,11 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
mystrcpy(buf1,"<RM>");
|
||||
mystrcpy(buf2,buf1);
|
||||
#endif
|
||||
if (parm1>=0)
|
||||
if (parm1)
|
||||
{
|
||||
sec=process_string_fromparm_tobuf(0x11);
|
||||
}
|
||||
if (parm2>=0)
|
||||
if (parm2)
|
||||
{
|
||||
ent=process_string_fromparm_tobuf(0x22);
|
||||
}
|
||||
|
@ -1142,7 +1142,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
int rootkey=parm0;
|
||||
char *buf3=process_string_fromparm_tobuf(0x31);
|
||||
exec_errorflag++;
|
||||
if (parm2 != -1)
|
||||
if (parm2)
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx((HKEY)rootkey,buf3,0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS)
|
||||
|
@ -1486,7 +1486,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
if (g_SectionHack)
|
||||
{
|
||||
int a;
|
||||
for (a = 0; a < x; a ++) if (g_inst_section[a].name_ptr>=0) z++;
|
||||
for (a = 0; a < x; a ++) if (g_inst_section[a].name_ptr) z++;
|
||||
}
|
||||
|
||||
if (parm1==0) //set text
|
||||
|
|
|
@ -115,8 +115,11 @@ const char * NSISCALL loadHeaders(void)
|
|||
|
||||
const char * NSISCALL GetStringFromStringTab(int offs)
|
||||
{
|
||||
if (offs < 0) return "";
|
||||
return g_db_strtab+offs;
|
||||
/*if (offs < 0) {
|
||||
wsprintf(ps_tmpbuf, "my first user madasd %d->%d which should be %d\n%d", offs, cur_user_strings_table[-(offs+1)], cur_user_strings_table[0], LANG_COMP_TEXT);
|
||||
my_MessageBox(ps_tmpbuf, MB_OK);
|
||||
}*/
|
||||
return g_db_strtab+(offs < 0 ? cur_user_strings_table[-(offs+1)] : offs);
|
||||
}
|
||||
|
||||
#define IBUFSIZE 16384
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// uninstall_header (~116 bytes)
|
||||
// entries (24 bytes each)
|
||||
// string table
|
||||
// language tables
|
||||
// datablock
|
||||
// (hdrinfo+datablock is at least 512 bytes if CRC enabled)
|
||||
// CRC (optional - 4 bytes)
|
||||
|
@ -273,16 +274,13 @@ typedef struct
|
|||
int output_dir;
|
||||
int create_dir;
|
||||
int copy_details;
|
||||
|
||||
// Note - should be at the end (everything before here should be just ints)
|
||||
WORD lang_id;
|
||||
|
||||
} common_strings;
|
||||
|
||||
// Settings common to both installers and uninstallers
|
||||
typedef struct
|
||||
{
|
||||
int str_tables_num; // number of strings tables in array
|
||||
int language_table_size; // size of each language table
|
||||
|
||||
int num_entries; // total number of entries
|
||||
int num_string_bytes; // total number of bytes taken by strings
|
||||
|
@ -311,12 +309,6 @@ typedef struct
|
|||
#endif//NSIS_CONFIG_SILENT_SUPPORT
|
||||
// additional flags
|
||||
char misc_flags; // auto_close=&1, no_show_dirpage=&2, no_show_icon&4, no_rootdir&8;
|
||||
|
||||
// Added by Amir Szekely 6th August 2002
|
||||
// Adds the ability to make the inner text show up in a dialog item in the outer dialog.
|
||||
/* Useless
|
||||
WORD intro_text_id;*/
|
||||
|
||||
} common_header;
|
||||
|
||||
// Strings specific to installers
|
||||
|
@ -388,18 +380,6 @@ typedef struct
|
|||
int code_onSelChange;
|
||||
#endif//NSIS_CONFIG_COMPONENTPAGE
|
||||
#endif//NSIS_SUPPORT_CODECALLBACKS
|
||||
|
||||
// Added by Amir Szekely 6th August 2002
|
||||
// Adds the ability to make the inner text show up in a dialog item in the outer dialog.
|
||||
/*
|
||||
Useless
|
||||
|
||||
WORD space_avail_id;
|
||||
WORD space_req_id;
|
||||
WORD dir_subtext_id;
|
||||
WORD com_subtext1_id;
|
||||
WORD com_subtext2_id;*/
|
||||
|
||||
} header;
|
||||
|
||||
// Strings specific to uninstallers
|
||||
|
@ -419,12 +399,6 @@ typedef struct
|
|||
|
||||
int code;
|
||||
int code_size;
|
||||
|
||||
// Added by Amir Szekely 6th August 2002
|
||||
// Adds the ability to make the inner text show up in a dialog item in the outer dialog.
|
||||
/* Useless
|
||||
WORD uninst_subtext_id;*/
|
||||
|
||||
} uninstall_header;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
#include "lang.h"
|
||||
|
||||
// Added by Amir Szekely 3rd August 2002
|
||||
extern char *language_tables;
|
||||
extern common_strings *cur_common_strings_table;
|
||||
extern char *cur_install_strings_table; // installer_strings/uninstall_strings depending on installer type
|
||||
extern char *cur_install_strings_table; // installer_strings/uninstall_strings depending on installer type
|
||||
extern int *cur_user_strings_table;
|
||||
|
||||
int NSISCALL ui_doinstall(void);
|
||||
void NSISCALL update_status_text_from_lang(langid_t id, const char *text2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue