Browse Source

+ start of multilanguage support

florian 25 years ago
parent
commit
52b929a482
3 changed files with 194 additions and 27 deletions
  1. 2 1
      install/fpinst/install.dat
  2. 149 26
      install/fpinst/install.pas
  3. 43 0
      install/fpinst/inststr.pas

+ 2 - 1
install/fpinst/install.dat

@@ -215,6 +215,7 @@ defaultcfg=
 #-Fr$1/msg/errores.msg
 #-Fr$1/msg/errores.msg
 #-Fr$1/msg/errord.msg
 #-Fr$1/msg/errord.msg
 #-Fr$1/msg/errorr.msg
 #-Fr$1/msg/errorr.msg
+-Fr$1/msg/$L
 
 
 # path to the gcclib
 # path to the gcclib
 #-Fl$1/lib
 #-Fl$1/lib
@@ -276,4 +277,4 @@ defaultcfg=
 #
 #
 # That's all folks
 # That's all folks
 #
 #
-endcfg
+endcfg

+ 149 - 26
install/fpinst/install.pas

@@ -74,7 +74,7 @@ program install;
 {$IFDEF DLL}
 {$IFDEF DLL}
      unzipdll,
      unzipdll,
 {$ENDIF}
 {$ENDIF}
-     app,dialogs,views,menus,msgbox,colortxt,tabs;
+     app,dialogs,views,menus,msgbox,colortxt,tabs,inststr;
 
 
 
 
   const
   const
@@ -132,6 +132,7 @@ program install;
      cfgrec=record
      cfgrec=record
        title    : string[80];
        title    : string[80];
        version  : string[20];
        version  : string[20];
+       language : string[30];
        basepath : DirStr;
        basepath : DirStr;
        packs    : word;
        packs    : word;
        pack     : array[1..maxpacks] of tpack;
        pack     : array[1..maxpacks] of tpack;
@@ -162,10 +163,16 @@ program install;
         constructor init;
         constructor init;
      end;
      end;
 
 
+     planguagedialog = ^tlanguagedialog;
+     tlanguagedialog = object(tdialog)
+        constructor init;
+     end;
+
      tapp = object(tapplication)
      tapp = object(tapplication)
          procedure initmenubar;virtual;
          procedure initmenubar;virtual;
          procedure handleevent(var event : tevent);virtual;
          procedure handleevent(var event : tevent);virtual;
          procedure do_installdialog;
          procedure do_installdialog;
+         procedure do_languagedialog;
          procedure readcfg(const fn:string);
          procedure readcfg(const fn:string);
          procedure checkavailpack;
          procedure checkavailpack;
      end;
      end;
@@ -207,6 +214,7 @@ program install;
      UnzDlg      : punzipdialog;
      UnzDlg      : punzipdialog;
      log         : text;
      log         : text;
      createlog   : boolean;
      createlog   : boolean;
+     msgfile     : string;
 {$IFNDEF DLL}
 {$IFNDEF DLL}
 
 
   const
   const
@@ -244,16 +252,18 @@ program install;
     end;
     end;
 
 
 
 
-  procedure Replace(var s:string;const s1,s2:string);
+  function Replace(var s:string;const s1,s2:string) : boolean;
     var
     var
        i  : longint;
        i  : longint;
     begin
     begin
+      Replace:=false;
       repeat
       repeat
         i:=pos(s1,s);
         i:=pos(s1,s);
         if i>0 then
         if i>0 then
          begin
          begin
            Delete(s,i,length(s1));
            Delete(s,i,length(s1));
            Insert(s2,s,i);
            Insert(s2,s,i);
+           Replace:=true;
          end;
          end;
       until i=0;
       until i=0;
     end;
     end;
@@ -325,7 +335,7 @@ program install;
       s : string;
       s : string;
     begin
     begin
       uncompressed:=DiskSpaceN (zipfile);
       uncompressed:=DiskSpaceN (zipfile);
-      if Uncompressed = -1 then DiskSpace := ' [INVALID]' else
+      if Uncompressed = -1 then DiskSpace := str_invalid else
       begin
       begin
        str(uncompressed,s);
        str(uncompressed,s);
        diskspace:=' ('+s+' KB)';
        diskspace:=' ('+s+' KB)';
@@ -346,13 +356,11 @@ program install;
          begin
          begin
             if Dir.Attr and Directory = 0 then
             if Dir.Attr and Directory = 0 then
               begin
               begin
-                messagebox('A file with the name chosen as the installation '+
-                'directory exists already. Cannot create this directory!',nil,
+                messagebox(msg_problems_create_dir,nil,
                 mferror+mfokbutton);
                 mferror+mfokbutton);
                 createinstalldir:=false;
                 createinstalldir:=false;
               end else
               end else
-                createinstalldir:=messagebox('The installation directory exists already. '+
-                'Do you want to continue ?',nil,
+                createinstalldir:=messagebox(msg_install_dir_exists,nil,
                 mferror+mfyesbutton+mfnobutton)=cmYes;
                 mferror+mfyesbutton+mfnobutton)=cmYes;
             exit;
             exit;
          end;
          end;
@@ -360,7 +368,7 @@ program install;
        if err then
        if err then
          begin
          begin
             params[0]:=@s;
             params[0]:=@s;
-            messagebox('The installation directory %s couldn''t be created',
+            messagebox(msg_install_cant_be_created,
               @params,mferror+mfokbutton);
               @params,mferror+mfokbutton);
             createinstalldir:=false;
             createinstalldir:=false;
             exit;
             exit;
@@ -406,7 +414,7 @@ program install;
       if doserror=0 then
       if doserror=0 then
        begin
        begin
          params[0]:=@fn;
          params[0]:=@fn;
-         if MessageBox('Config %s already exists, continue writing default config?',@params,
+         if MessageBox(msg_overwrite_cfg,@params,
                        mfinformation+mfyesbutton+mfnobutton)=cmNo then
                        mfinformation+mfyesbutton+mfnobutton)=cmNo then
            exit;
            exit;
        end;
        end;
@@ -421,7 +429,7 @@ program install;
       if ioresult<>0 then
       if ioresult<>0 then
        begin
        begin
          params[0]:=@fn;
          params[0]:=@fn;
-         MessageBox(#3'Default config not written.'#13#3'%s'#13#3'couldn''t be created',@params,mfinformation+mfokbutton);
+         MessageBox(msg_problems_writing_cfg,@params,mfinformation+mfokbutton);
          exit;
          exit;
        end;
        end;
       for i:=1 to cfg.defcfgs do
       for i:=1 to cfg.defcfgs do
@@ -429,10 +437,21 @@ program install;
          begin
          begin
            s:=cfg.defcfg[i]^;
            s:=cfg.defcfg[i]^;
            Replace(s,'$1',data.basepath);
            Replace(s,'$1',data.basepath);
-           writeln(t,s);
+
+           { error msg file entry? }
+           if Replace(s,'$L',msgfile) then
+             begin
+                { if we've to set an error msg file, we }
+                { write it else we discard the line     }
+                if msgfile<>'' then
+                  writeln(t,s);
+             end
+           else
+             writeln(t,s);
          end
          end
        else
        else
          writeln(t,'');
          writeln(t,'');
+
       close(t);
       close(t);
     end;
     end;
 
 
@@ -570,7 +589,7 @@ program install;
 {$ENDIF}
 {$ENDIF}
 
 
       R.Assign(6, 6, 74, YB);
       R.Assign(6, 6, 74, YB);
-      inherited init(r,'Installation Successfull');
+      inherited init(r,dialog_enddialog_title);
 
 
 {$IFNDEF LINUX}
 {$IFNDEF LINUX}
       if WPath then
       if WPath then
@@ -643,6 +662,45 @@ program install;
        haslfn:=islfn;
        haslfn:=islfn;
     end;
     end;
 
 
+  constructor tlanguagedialog.init;
+    const
+       languages = 8;
+       width = 40;
+       height = languages+5;
+       x1 = (79-width) div 2;
+       y1 = (23-height) div 2;
+       x2 = x1+width;
+       y2 = y1+height;
+    var
+       r : trect;
+       okbut : pbutton;
+       line : longint;
+       rb : PRadioButtons;
+
+    begin
+       r.assign(x1,y1,x2,y2);
+       inherited init(r,dialog_language_title);
+       GetExtent(R);
+       R.Grow(-2,-1);
+       line:=r.a.y+1;
+       r.assign((width div 2)-15,line,(width div 2)+15,line+7);
+       New(rb, Init(r,
+          NewSItem(dialog_language_english,
+          NewSItem(dialog_language_dutch,
+          NewSItem(dialog_language_french,
+          NewSItem(dialog_language_russian,
+          NewSItem(dialog_language_hungarian,
+          NewSItem(dialog_language_spanish,
+          NewSItem(dialog_language_german,nil)))))))));
+       insert(rb);
+       inc(line,7);
+       inc(line,1);
+       r.assign((width div 2)-5,line,(width div 2)+5,line+2);
+       new(okbut,init(r,'~O~k',cmok,bfdefault));
+
+      Insert(OkBut);
+    end;
+
   constructor tinstalldialog.init;
   constructor tinstalldialog.init;
     const
     const
        width = 76;
        width = 76;
@@ -690,13 +748,13 @@ program install;
                            packmask[j]:=packmask[j] or packagemask(i);
                            packmask[j]:=packmask[j] or packagemask(i);
                            firstitem[j]:=i;
                            firstitem[j]:=i;
                            if createlog then
                            if createlog then
-                             writeln(log,'Checking lfn usage for ',startpath+DirSep+package[i].zip,' ... no lfn');
+                             writeln(log,str_checking_lfn,startpath+DirSep+package[i].zip,' ... no lfn');
                         end
                         end
                       else
                       else
                         begin
                         begin
-                           items[j]:=newsitem(package[i].name+' (requires LFN support)',items[j]);
+                           items[j]:=newsitem(package[i].name+str_requires_lfn,items[j]);
                            if createlog then
                            if createlog then
-                             writeln(log,'Checking lfn usage for ',startpath+DirSep+package[i].zip,' ... uses lfn');
+                             writeln(log,str_checking_lfn,startpath+DirSep+package[i].zip,' ... uses lfn');
                         end;
                         end;
                    end
                    end
                  else
                  else
@@ -719,7 +777,7 @@ program install;
          found:=true;
          found:=true;
        if not found then
        if not found then
         begin
         begin
-          messagebox('No components found to install, aborting.',nil,mferror+mfokbutton);
+          messagebox(msg_no_components_found,nil,mferror+mfokbutton);
           errorhalt;
           errorhalt;
         end;
         end;
 
 
@@ -799,6 +857,59 @@ program install;
     end;
     end;
 
 
 
 
+{*****************************************************************************
+                               TUnZipDialog
+*****************************************************************************}
+
+  procedure tapp.do_languagedialog;
+
+    var
+       p : planguagedialog;
+       langdata : longint;
+       c : word;
+
+    begin
+       { select components }
+       new(p,init);
+       langdata:=0;
+       c:=executedialog(p,@langdata);
+       writeln(langdata);
+       if c=cmok then
+         begin
+            case langdata of
+               0:
+                 cfg.language:='English';
+               1:
+                 begin
+                    cfg.language:='Dutch';
+                    msgfile:='errorn.msg';
+                 end;
+               2:
+                 begin
+                    cfg.language:='French';
+                    msgfile:='errorf.msg';
+                 end;
+               3:
+                 begin
+                    cfg.language:='Russian';
+                    msgfile:='errorr.msg';
+                 end;
+               4:
+                 cfg.language:='Hungarian';
+               5:
+                 begin
+                    cfg.language:='Spanish';
+                    msgfile:='errors.msg';
+                 end;
+               6:
+                 begin
+                    cfg.language:='German';
+                    msgfile:='errord.msg';
+                 end;
+            end;
+         end;
+    end;
+
 {*****************************************************************************
 {*****************************************************************************
                                 TApp
                                 TApp
 *****************************************************************************}
 *****************************************************************************}
@@ -832,7 +943,7 @@ program install;
         if (c=cmok) then
         if (c=cmok) then
           begin
           begin
             if Data.BasePath = '' then
             if Data.BasePath = '' then
-              messagebox('Please, choose the directory for installation first.',nil,mferror+mfokbutton)
+              messagebox(msg_select_dir,nil,mferror+mfokbutton)
             else
             else
              begin
              begin
                found:=false;
                found:=false;
@@ -888,7 +999,7 @@ program install;
                   { maybe only config }
                   { maybe only config }
                   if (data.cfgval and 1)<>0 then
                   if (data.cfgval and 1)<>0 then
                    begin
                    begin
-                     result:=messagebox('No components selected.'#13#13'Create a configfile ?',nil,
+                     result:=messagebox(msg_no_components_selected,nil,
                                                 mfinformation+mfyesbutton+mfnobutton);
                                                 mfinformation+mfyesbutton+mfnobutton);
                      if (result=cmYes) and createinstalldir(data.basepath) then
                      if (result=cmYes) and createinstalldir(data.basepath) then
                       begin
                       begin
@@ -900,7 +1011,7 @@ program install;
                    end
                    end
                   else
                   else
                    begin
                    begin
-                     result:=messagebox('No components selected.'#13#13'Abort installation?',nil,
+                     result:=messagebox(msg_nocomponents,nil,
                                                mferror+mfyesbutton+mfnobutton);
                                                mferror+mfyesbutton+mfnobutton);
                      if result=cmYes then
                      if result=cmYes then
                       exit;
                       exit;
@@ -917,7 +1028,7 @@ program install;
        with cfg.pack[j] do
        with cfg.pack[j] do
         begin
         begin
           r.assign(20,7,60,16);
           r.assign(20,7,60,16);
-          UnzDlg:=new(punzipdialog,init(r,'Extracting Packages'));
+          UnzDlg:=new(punzipdialog,init(r,dialog_unzipdialog_title));
           desktop^.insert(UnzDlg);
           desktop^.insert(UnzDlg);
           for i:=1 to packages do
           for i:=1 to packages do
            begin
            begin
@@ -989,7 +1100,7 @@ program install;
          if ioresult<>0 then
          if ioresult<>0 then
           begin
           begin
             params[0]:=@fn;
             params[0]:=@fn;
-            messagebox('File %s not found!',@params,mferror+mfokbutton);
+            messagebox(msg_file_not_found,@params,mferror+mfokbutton);
             errorhalt;
             errorhalt;
           end;
           end;
        end;
        end;
@@ -1010,6 +1121,9 @@ program install;
                else
                else
                 if item='TITLE' then
                 if item='TITLE' then
                  cfg.title:=s
                  cfg.title:=s
+               else
+                if item='LANGUAGE' then
+                 cfg.language:=s
                else
                else
                 if item='BASEPATH' then
                 if item='BASEPATH' then
                  cfg.basepath:=s
                  cfg.basepath:=s
@@ -1139,7 +1253,7 @@ program install;
        getextent(r);
        getextent(r);
        r.b.y:=r.a.y+1;
        r.b.y:=r.a.y+1;
        menubar:=new(pmenubar,init(r,newmenu(
        menubar:=new(pmenubar,init(r,newmenu(
-          newsubmenu('Free Pascal Installer',hcnocontext,newmenu(nil
+          newsubmenu(menu_install,hcnocontext,newmenu(nil
           ),
           ),
        nil))));
        nil))));
     end;
     end;
@@ -1294,16 +1408,22 @@ begin
    fillchar(cfg, SizeOf(cfg), 0);
    fillchar(cfg, SizeOf(cfg), 0);
    fillchar(data, SizeOf(data), 0);
    fillchar(data, SizeOf(data), 0);
 
 
+   { set a default language }
+   cfg.language:='English';
+
+   { don't use a message file by default }
+   msgfile:='';
+
    installapp.init;
    installapp.init;
 
 
    FSplit (FExpand (ParamStr (0)), DStr, CfgName, EStr);
    FSplit (FExpand (ParamStr (0)), DStr, CfgName, EStr);
 
 
    installapp.readcfg(CfgName + CfgExt);
    installapp.readcfg(CfgName + CfgExt);
    installapp.checkavailpack;
    installapp.checkavailpack;
+   installapp.do_languagedialog;
 {   installapp.readcfg(startpath+dirsep+cfgfile);}
 {   installapp.readcfg(startpath+dirsep+cfgfile);}
    if not(lfnsupport) then
    if not(lfnsupport) then
-     MessageBox('The operating system doesn''t support LFN (long file names),'+
-       ' so some packages won''t be installed',nil,mfinformation or mfokbutton);
+     MessageBox(msg_no_lfn,nil,mfinformation or mfokbutton);
    installapp.do_installdialog;
    installapp.do_installdialog;
    installapp.done;
    installapp.done;
    if createlog then
    if createlog then
@@ -1311,7 +1431,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-09-17 14:44:12  hajny
+  Revision 1.4  2000-09-21 22:09:23  florian
+    + start of multilanguage support
+
+  Revision 1.3  2000/09/17 14:44:12  hajny
     * compilable with TP again
     * compilable with TP again
 
 
   Revision 1.2  2000/07/21 10:43:01  florian
   Revision 1.2  2000/07/21 10:43:01  florian
@@ -1428,4 +1551,4 @@ end.
   Revision 1.2  1998/04/07 22:47:57  florian
   Revision 1.2  1998/04/07 22:47:57  florian
     + version/release/patch numbers as string added
     + version/release/patch numbers as string added
 
 
-}
+}

+ 43 - 0
install/fpinst/inststr.pas

@@ -0,0 +1,43 @@
+{$MODE OBJFPC}
+unit inststr;
+
+  interface
+
+    resourcestring
+       dialog_language_title = 'Please choose your language';
+       dialog_language_english = 'English';
+       dialog_language_dutch = 'Dutch';
+       dialog_language_french = 'French';
+       dialog_language_russian = 'Russian';
+       dialog_language_hungarian = 'Hungarian';
+       dialog_language_spanish = 'Spanish';
+       dialog_language_german = 'German';
+
+       dialog_enddialog_title = 'Installation Successfull';
+
+       dialog_unzipdialog_title = 'Extracting Packages';
+
+       msg_nocomponents = 'No components selected.'#13#13'Abort installation?';
+       msg_overwrite_cfg = 'Config %s already exists, continue writing default config?';
+       msg_problems_writing_cfg = #3'Default config not written.'#13#3'%s'#13#3'couldn''t be created';
+       msg_problems_create_dir = 'A file with the name chosen as the installation '+
+                                 'directory exists already. Cannot create this directory!';
+       msg_no_components_selected = 'No components selected.'#13#13'Create a configfile ?';
+       msg_select_dir = 'Please, choose the directory for installation first.';
+       msg_no_components_found = 'No components found to install, aborting.';
+       msg_install_dir_exists = 'The installation directory exists already. '+
+                                'Do you want to continue ?';
+       msg_install_cant_be_created = 'The installation directory %s couldn''t be created';
+       msg_file_not_found = 'File %s not found!';
+       msg_no_lfn = 'The operating system doesn''t support LFN (long file names),'+
+                    ' so some packages won''t be installed';
+
+       menu_install = 'Free Pascal Installer';
+
+       str_requires_lfn = ' (requires LFN support)';
+       str_checking_lfn = 'Checking lfn usage for ';
+       str_invalid = ' [INVALID]';
+
+  implementation
+
+end.