Translation update done using Pootle.
[wammu.git] / wammu.iss
blobb36b905e4cd17564dd1321eaa6970dd70b061168
1 ; Inno Setup Script for Wammu installation
2 ; Copyright (c) 2006 Michal Èihaø
3 ; Language selection code based on GTK+ 2 installation script
4 ; made by Jernej Simoncic, <jernej.simoncic@guest.arnes.si>
6 #define MyAppDosName "wammu"
7 #define MyAppName "Wammu"
8 #define MyAppVersion "0.36"
9 #define MyAppPublisher "Micha Èihaø"
10 #define MyAppURL "http://wammu.eu/"
11 #define MyAppPublisherURL "http://cihar.com/"
12 #define MyAppBugsURL "http://bugs.wammu.eu/"
13 #define MyAppDescription "Wammu Mobile Phone Manager"
14 #define MyAppExeName "wammu.exe"
15 #define MyAppUrlName "wammu.url"
16 #define MyAppBugsUrlName "wammu-bugs.url"
18 [Setup]
19 AppName={#MyAppName}
20 AppVerName={#MyAppName} {#MyAppVersion}
21 AppPublisher={#MyAppPublisher}
22 AppPublisherURL={#MyAppPublisherURL}
23 AppSupportURL={#MyAppBugsURL}
24 AppUpdatesURL={#MyAppURL}
25 DefaultDirName={pf}\{#MyAppName}
26 DefaultGroupName={#MyAppName}
27 AllowNoIcons=true
28 LicenseFile=COPYING
29 OutputBaseFilename={#MyAppDosName}-{#MyAppVersion}-setup
30 Compression=lzma/ultra
31 SolidCompression=true
32 InternalCompressLevel=ultra
33 VersionInfoVersion={#MyAppVersion}
34 VersionInfoCompany={#MyAppPublisher}
35 VersionInfoDescription={#MyAppDescription}
36 ShowLanguageDialog=yes
37 AppVersion={#MyAppVersion}
38 UninstallDisplayIcon={app}\share\pixmaps\wammu.ico
39 AppModifyPath="{uninstallexe}" /langsetup
40 ChangesEnvironment=true
41 ;SetupIconFile={app}\icon\wammu.ico
43 [Languages]
44 Name: en; MessagesFile: compiler:Default.isl
45 ;Name: af; MessagesFile: compiler:Languages\Afrikaans.isl
46 Name: ca; MessagesFile: compiler:Languages\Catalan.isl
47 Name: cs; MessagesFile: compiler:Languages\Czech.isl
48 Name: de; MessagesFile: compiler:Languages\German.isl
49 ;Name: el; MessagesFile: compiler:Languages\Greek.isl
50 Name: es; MessagesFile: compiler:Languages\Spanish.isl
51 ;Name: et; MessagesFile: compiler:Languages\Estonian.isl
52 Name: fi; MessagesFile: compiler:Languages\Finnish.isl
53 Name: fr; MessagesFile: compiler:Languages\French.isl
54 ;Name: gl; MessagesFile: compiler:Languages\Galician.isl
55 Name: he; MessagesFile: compiler:Languages\Hebrew.isl
56 Name: hu; MessagesFile: compiler:Languages\Hungarian.isl
57 ;Name: id; MessagesFile: compiler:Languages\Indonesian.isl
58 Name: it; MessagesFile: compiler:Languages\Italian.isl
59 ;Name: ko; MessagesFile: compiler:Languages\Korean.isl
60 Name: nl; MessagesFile: compiler:Languages\Dutch.isl
61 Name: pl; MessagesFile: compiler:Languages\Polish.isl
62 Name: pt_BR; MessagesFile: compiler:Languages\BrazilianPortuguese.isl
63 Name: ru; MessagesFile: compiler:Languages\Russian.isl
64 Name: sk; MessagesFile: compiler:Languages\Slovak.isl
65 ;Name: sv; MessagesFile: compiler:Languages\Swedish.isl
66 ;Name: zh_tw; MessagesFile: compiler:Languages\SimpChinese.isl
67 ;Name: zh_cz; MessagesFile: compiler:Languages\TradChinese.isl
69 [Tasks]
70 Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
72 [Files]
73 Source: dist\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: locale
74 Source: uninst.isl; DestDir: {app}
75 Source: dist\share\locale\*; DestDir: {app}\share\locale; Flags: ignoreversion recursesubdirs createallsubdirs; Components: " Translations"; Tasks: ; Languages:
77 [INI]
78 Filename: {app}\{#MyAppUrlName}; Section: InternetShortcut; Key: URL; String: {#MyAppURL}
79 Filename: {app}\{#MyAppBugsUrlName}; Section: InternetShortcut; Key: URL; String: {#MyAppBugsURL}
81 [Icons]
82 Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; IconFilename: {app}\share\pixmaps\wammu.ico; IconIndex: 0
83 Name: {group}\{cm:ProgramOnTheWeb,{#MyAppName}}; Filename: {app}\{#MyAppUrlName}
84 Name: {group}\{cm:ReportBug,{#MyAppName}}; Filename: {app}\{#MyAppBugsUrlName}
85 Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
86 Name: {userdesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon
87 Name: {group}\{cm:SelectLanguage}; Filename: {uninstallexe}; Parameters: /langsetup; IconFilename: {app}\share\pixmaps\wammu.ico; IconIndex: 0
89 [Run]
90 Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent unchecked
91 Filename: {uninstallexe}; Parameters: /langsetup; Description: {cm:SelectLanguage}; Flags: postinstall nowait
93 [Components]
94 Name: Translations; Description: {cm:TranslationsDesc}; Types: custom full; Languages:
96 [UninstallDelete]
97 Type: files; Name: {app}\{#MyAppUrlName}
98 Type: files; Name: {app}\{#MyAppBugsUrlName}
100 [CustomMessages]
101 en.ReportBug=Report bug in application %1
102 cs.ReportBug=Nahlásit chybu v aplikaci %1
103 en.SelectLanguage=Select application language
104 cs.SelectLanguage=Zvolit jazyk aplikace
105 en.Translations=Translations
106 en.TranslationsDesc=Translations of user interface
107 cs.Translations=Pøeklady
108 cs.TranslationsDesc=Pøeklady uživatelského rozhraní
110 [Registry]
111 Root: HKCU; Subkey: Environment; ValueType: string; ValueName: LANG; ValueData: {language}; Check: UsingWinNT
113 ; Following part is heavily based on GTK+ 2 setup
114 [Code]
115 program Setup;
117 function SendMessageTimeout(hWnd: HWND; Msg: Cardinal; wParam: DWORD; lParam: String; fuFlags, uTimeout: Cardinal; lpdwResult: DWORD): {Int64}Cardinal; external 'SendMessageTimeoutA@user32 stdcall';
120 frmLangChooser: TForm;
121 cbUser, cbSystem: TComboBox;
123 const
124 WM_SETTINGCHANGE = 26;
125 //HWND_BROADCAST = $FFFF;
126 SMTO_ABORTIFHUNG = 2;
128 function RevPos(const SearchStr, Str: string): Integer;
129 var i: Integer;
130 begin
132 if (Length(SearchStr) < Length(Str)) and (Pos(SearchStr, Str) > 0) then
133 for i := (Length(Str) - Length(SearchStr) + 1) downto 1 do
134 begin
136 if Copy(Str, i, Length(SearchStr)) = SearchStr then
137 begin
138 Result := i;
139 exit;
140 end;
142 end;
144 Result := 0;
145 end;
148 function ExtractLang(const Txt: String): String;
149 var S: String;
150 i: Integer;
151 begin
152 S := LowerCase(Txt);
153 if (S[Length(S)] = ')') then
154 begin
155 i := RevPos('(',S);
156 if (i > 0) then
157 S := Copy(Txt,i+1,Length(Txt)-i-1)
158 else
159 S := Txt;
160 end else
161 S := Txt;
163 Result := S;
164 end;
167 function GetLangIndex(Items: TStrings; Lang: String): Integer;
168 var i: Integer;
169 s: String;
170 begin
171 Lang := LowerCase(Lang);
172 for i := 0 to Items.Count - 1 do
173 begin
174 S := LowerCase(ExtractLang(Items.Strings[i]));
175 if (S = Lang) then
176 break;
177 end;
179 if (i >= Items.Count) then
180 Result := -1
181 else
182 Result := i;
183 end;
186 function GetTransStr(const Str: String): String; //ExpandConstant('{cm:...}') doesn't work on uninstall
187 begin
188 Result := GetIniString('CustomMessages',Str,'',ExpandConstant('{app}\uninst.isl'));
190 if (Result = '') then
191 RaiseException(Str + ' not found in translation file.');
192 end;
195 procedure LanguageForm;
196 var lblInfo, lblUser, lblSystem: TLabel;
197 btnOK,btnCancel: TButton;
198 frMsgs: TFindRec;
199 i,j: Integer;
200 lang1,lang2,regSys,regUser: String;
201 AutoExec: TArrayOfString;
202 MsgResult: DWORD;
203 begin
205 frmLangChooser := CreateCustomForm();
207 with frmLangChooser do
208 begin
209 ClientWidth := ScaleX(321);
210 ClientHeight := ScaleY(119);
211 Caption := GetTransStr('LangTitle');
212 Position := poScreenCenter;
213 end;
215 { lblInfo }
216 lblInfo := TLabel.Create(frmLangChooser);
217 with lblInfo do
218 begin
219 Parent := frmLangChooser;
220 Left := ScaleX(8);
221 Top := ScaleY(8);
222 Width := ScaleX(283);
223 Height := ScaleY(13);
224 Caption := GetTransStr('LangText');
225 end;
227 { lblUser }
228 lblUser := TLabel.Create(frmLangChooser);
229 with lblUser do
230 begin
231 Parent := frmLangChooser;
232 Left := ScaleX(8);
233 Top := ScaleY(34);
234 Width := ScaleX(119);
235 Height := ScaleY(13);
236 Caption := GetTransStr('LangUser');
237 FocusControl := cbUser;
238 end;
240 { lblSystem }
241 lblSystem := TLabel.Create(frmLangChooser);
242 with lblSystem do
243 begin
244 Parent := frmLangChooser;
245 Left := ScaleX(8);
246 Top := ScaleY(58);
247 Width := ScaleX(93);
248 Height := ScaleY(13);
249 Caption := GetTransStr('LangSystem');
250 FocusControl := cbSystem;
251 end;
253 { cbUser }
254 cbUser := TComboBox.Create(frmLangChooser);
255 with cbUser do
256 begin
257 Parent := frmLangChooser;
258 Style := csDropDownList;
259 Left := ScaleX(144);
260 Top := ScaleY(32);
261 Width := ScaleX(169);
262 Height := ScaleY(16);
263 Hint := GetTransStr('LangUserHint');
264 ShowHint := True;
265 TabOrder := 0;
266 Sorted := True;
267 end;
269 { cbSystem }
270 cbSystem := TComboBox.Create(frmLangChooser);
271 with cbSystem do
272 begin
273 Parent := frmLangChooser;
274 Style := csDropDownList;
275 Left := ScaleX(144);
276 Top := ScaleY(56);
277 Width := ScaleX(169);
278 Height := ScaleY(16);
279 Hint := GetTransStr('LangSystemHint');
280 ShowHint := True;
281 TabOrder := 1;
282 Sorted := True;
283 end;
285 { btnOK }
286 btnOK := TButton.Create(frmLangChooser);
287 with btnOK do
288 begin
289 Parent := frmLangChooser;
290 Left := ScaleX(82);
291 Top := ScaleY(88);
292 Width := ScaleX(75);
293 Height := ScaleY(23);
294 Caption := SetupMessage(msgButtonOK);
295 Default := True;
296 TabOrder := 2;
297 ModalResult := 1;
298 end;
300 { btnCancel }
301 btnCancel := TButton.Create(frmLangChooser);
302 with btnCancel do
303 begin
304 Parent := frmLangChooser;
305 Left := ScaleX(164);
306 Top := ScaleY(88);
307 Width := ScaleX(75);
308 Height := ScaleY(23);
309 Caption := SetupMessage(msgButtonCancel);
310 Cancel := True;
311 TabOrder := 3;
312 ModalResult := 2;
313 end;
315 cbUser.Items.Add(GetTransStr('LangDefault'));
316 cbUser.Items.Add('English (C)');
317 //cbSystem.Items.Add(GetTransStr('LangDefault'));
319 if FindFirst(ExpandConstant('{app}\share\locale\*'),frMsgs) then
320 begin
323 repeat
324 if ((frMsgs.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and ((frMsgs.Name <> '.') and (frMsgs.Name <> '..')) then
325 begin
328 lang1 := frMsgs.Name;
329 StringChange(lang1,'@','_'); //custom messages only support letters,numbers and _
330 lang1 := GetTransStr('Lang_'+lang1+'');
331 except
332 lang1 := '';
333 end;
335 i := pos('@',frMsgs.Name);
336 if (lang1 = '') and (i > 0) then
338 lang1 := GetTransStr('Lang_'+Copy(frMsgs.Name,1,i-1)+'');
339 lang2 := Copy(frMsgs.Name,i+1,length(frMsgs.Name))
340 except
341 lang1 := '';
342 end;
344 if (lang1 = '') and (Length(frMsgs.Name) > 2) then
346 lang1 := GetTransStr('Lang_'+Copy(frMsgs.Name,1,2)+'');
347 except
348 lang1 := '';
349 end;
351 case lowercase(lang2) of
352 'latn': lang2 := 'Latin';
353 end;
355 if (lang1 <> '') then
356 begin
357 if (lang2 <> '') then
358 begin
359 cbUser.Items.Add(lang1+' '+lang2+' ('+frMsgs.Name+')');
360 end else
361 begin
362 cbUser.Items.Add(lang1+' ('+frMsgs.Name+')');
364 end else
365 begin
366 cbUser.Items.Add(frMsgs.Name);
367 end;
369 end;
370 until not FindNext(frMsgs);
372 cbSystem.Items := cbUser.Items;
374 finally
375 FindClose(frMsgs);
376 end;
377 end;
379 if UsingWinNT then
380 begin
381 if not IsAdminLoggedOn then //only admins can change system-wide environment variables
382 begin
383 cbSystem.Enabled := False;
384 lblSystem.Enabled := False;
385 end;
387 if RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG',regSys) then
388 cbSystem.ItemIndex := GetLangIndex(cbSystem.Items,regSys)
389 else
390 cbSystem.ItemIndex := 0;
392 if cbSystem.ItemIndex = -1 then
393 cbSystem.ItemIndex := cbSystem.Items.Add(regSys);
396 if RegQueryStringValue(HKEY_CURRENT_USER,'Environment','LANG',regUser) then
397 cbUser.ItemIndex := GetLangIndex(cbSystem.Items,regUser)
398 else
399 cbUser.ItemIndex := 0;
401 if cbUser.ItemIndex = -1 then
402 cbUser.ItemIndex := cbUser.Items.Add(regUser);
403 end;
406 if frmLangChooser.ShowModal = 1 then
407 begin
408 regSys := ExtractLang(cbSystem.Items.Strings[cbSystem.ItemIndex]);
410 if UsingWinNT then
411 begin
412 regUser := ExtractLang(cbUser.Items.Strings[cbUser.ItemIndex]);
414 if cbUser.ItemIndex <> 0 then
415 begin
416 if not RegWriteStringValue(HKEY_CURRENT_USER,'Environment','LANG',regUser) then
417 MsgBox(GetTransStr('LangRegUserFailed'),mbCriticalError,mb_ok);
418 end else
419 if RegValueExists(HKEY_CURRENT_USER,'Environment','LANG') and
420 (not RegDeleteValue(HKEY_CURRENT_USER,'Environment','LANG')) then
421 MsgBox(GetTransStr('LangRegUserFailed'),mbCriticalError,mb_ok);
423 if IsAdminLoggedOn then
424 begin
425 if cbSystem.ItemIndex <> 0 then
426 begin
427 if not RegWriteStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG',regSys) then
428 MsgBox(GetTransStr('LangRegSysFailed'),mbCriticalError,mb_ok);
429 end else
430 if RegValueExists(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG') and
431 (not RegDeleteValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG')) then
432 MsgBox(GetTransStr('LangRegSysFailed'),mbCriticalError,mb_ok);
433 end;
435 //straight from the Inno source
436 SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment', SMTO_ABORTIFHUNG, 5000, MsgResult);
438 end else
439 begin
440 if not FileCopy(ExpandConstant('{sd}\AutoExec.bat'),ExpandConstant('{sd}\AutoExec.WAM'),False) then
441 if MsgBox(GetTransStr('LangAutoExecBackupFailed'),mbConfirmation,mb_yesno) = idno then
442 exit;
444 if LoadStringsFromFile(ExpandConstant('{sd}\Autoexec.bat'), AutoExec) then
445 begin
446 for i := GetArrayLength(AutoExec) - 1 downto 0 do
447 if pos('set lang=',LowerCase(AutoExec[i])) > 0 then
448 if (i>0) and (i<(GetArrayLength(AutoExec)-1))
449 and (LowerCase(AutoExec[i-1]) = 'REM /=== by Wammu Language Setup ===\')
450 and (LowerCase(AutoExec[i+1]) = 'REM \=== by Wammu Language Setup ===/') then
451 begin
452 for j := i to GetArrayLength(AutoExec) - 2 do //remove previous setting
453 AutoExec[j-1] := AutoExec[j+1];
454 SetArrayLength(AutoExec,GetArrayLength(AutoExec) - 3);
455 end;
457 i := GetArrayLength(AutoExec);
458 SetArrayLength(AutoExec,i + 3);
459 AutoExec[i] := 'REM /=== by Wammu Language Setup ===\';
460 AutoExec[i+1] := 'SET LANG='+regSys;
461 AutoExec[i+2] := 'REM \=== by Wammu Language Setup ===/';
463 if SaveStringsToFile(ExpandConstant('{sd}\AutoExec.bat'),AutoExec,False) then
464 MsgBox(GetTransStr('LangRestartRequired'),mbInformation,mb_ok)
465 else
466 MsgBox(GetTransStr('LangErrorSavingAutoExec'),mbCriticalError,mb_ok);
468 end else
469 MsgBox(GetTransStr('LangErrorLoadingAutoExec'), mbCriticalError, MB_OK);
470 end;
471 end;
473 end;
476 function InitializeUninstall(): Boolean;
477 var i: Integer;
478 begin
480 Result := True;
482 for i := 1 to ParamCount do
483 begin
484 if LowerCase(ParamStr(i)) = '/langsetup' then
485 begin
486 LanguageForm;
487 Result := False;
488 break;
489 end;
490 end;
493 end;
495 begin
496 end.
498 ; vim: fileencoding=windows-1250 fencs=windows-1250: