浏览代码

Language follows the environment; version change

Arthur Yefimov 3 年之前
父节点
当前提交
75c3942052
共有 3 个文件被更改,包括 25 次插入5 次删除
  1. 1 1
      src/Config.Mod
  2. 11 0
      src/Env.Mod
  3. 13 4
      src/FreeOberon.Mod

+ 1 - 1
src/Config.Mod

@@ -4,6 +4,6 @@ CONST
   isWindows* = Platform.Windows;
   isWindows* = Platform.Windows;
   stdPath* = 'Programs/';
   stdPath* = 'Programs/';
 
 
-  version* = '1.1.0-alpha.5';
+  version* = '1.1.0-alpha.6';
   year* = 2022;
   year* = 2022;
 END Config.
 END Config.

+ 11 - 0
src/Env.Mod

@@ -50,6 +50,17 @@ BEGIN
   END
   END
 END GetAppDir;
 END GetAppDir;
 
 
+PROCEDURE GetLang*(VAR s: ARRAY OF CHAR);
+BEGIN
+  GetByName('LANGUAGE', s);
+  IF s = '' THEN
+    GetByName('LC_ALL', s);
+    IF s = '' THEN
+      GetByName('LANG', s)
+    END
+  END
+END GetLang;
+
 BEGIN
 BEGIN
   count := -1
   count := -1
 END Env.
 END Env.

+ 13 - 4
src/FreeOberon.Mod

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 You should have received a copy of the GNU General Public License
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 *)
 *)
-IMPORT T := TermBox, Files, Args, Utf8, Builder,
+IMPORT T := TermBox, Files, Args, Utf8, Builder, Env,
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
 CONST
 CONST
   (* Direction of Selection *)
   (* Direction of Selection *)
@@ -760,6 +760,7 @@ BEGIN
   (*!TODO*) m.children.prev.status := OV.disabled;
   (*!TODO*) m.children.prev.status := OV.disabled;
   FoStrings.Get('menuLanguage', s);
   FoStrings.Get('menuLanguage', s);
   OV.Add(m, OV.NewMenu(s, '', 0, OptionsLanguage));
   OV.Add(m, OV.NewMenu(s, '', 0, OptionsLanguage));
+  (*!TODO*) m.children.prev.status := OV.disabled;
   FoStrings.Get('menuCompiler', s);
   FoStrings.Get('menuCompiler', s);
   OV.Add(m, OV.NewMenu(s, '', 0, NIL));
   OV.Add(m, OV.NewMenu(s, '', 0, NIL));
   (*!TODO*) m.children.prev.status := OV.disabled;
   (*!TODO*) m.children.prev.status := OV.disabled;
@@ -822,6 +823,7 @@ BEGIN
   OV.Add(m, OV.NewMenu('-', '', 0, NIL));
   OV.Add(m, OV.NewMenu('-', '', 0, NIL));
   FoStrings.Get('menuSizeMove', s);
   FoStrings.Get('menuSizeMove', s);
   OV.Add(m, OV.NewMenu(s, 'Ctrl+F5', OV.hCtrlF5, NIL));
   OV.Add(m, OV.NewMenu(s, 'Ctrl+F5', OV.hCtrlF5, NIL));
+  (*!TODO*) m.children.prev.status := OV.disabled;
   FoStrings.Get('menuZoom', s);
   FoStrings.Get('menuZoom', s);
   OV.Add(m, OV.NewMenu(s, 'F5', OV.hF5, OV.ZoomCurWindow));
   OV.Add(m, OV.NewMenu(s, 'F5', OV.hF5, OV.ZoomCurWindow));
   FoStrings.Get('menuNextWindow', s);
   FoStrings.Get('menuNextWindow', s);
@@ -911,12 +913,18 @@ BEGIN i := 0; w := 0; h := 0;
   Strings.Extract(s, i + 1, 30, x); h := Int.Val(x)
   Strings.Extract(s, i + 1, 30, x); h := Int.Val(x)
 END ParseSize;
 END ParseSize;
 
 
+PROCEDURE IdentifyLanguage(VAR lang: ARRAY OF CHAR);
+BEGIN
+  Env.GetLang(lang); lang[2] := 0X;
+  IF ~FoStrings.LangExists(lang) THEN lang := defLang END
+END IdentifyLanguage;
+
 PROCEDURE ParseArgs(VAR fs, sw: BOOLEAN; VAR w, h: INTEGER;
 PROCEDURE ParseArgs(VAR fs, sw: BOOLEAN; VAR w, h: INTEGER;
     VAR lang: ARRAY OF CHAR; VAR fnames: Fnames);
     VAR lang: ARRAY OF CHAR; VAR fnames: Fnames);
 VAR i, nofnames: INTEGER;
 VAR i, nofnames: INTEGER;
   s: ARRAY 2048 OF CHAR;
   s: ARRAY 2048 OF CHAR;
 BEGIN fs := TRUE; sw := FALSE; i := 1; nofnames := 0; w := defW; h := defH;
 BEGIN fs := TRUE; sw := FALSE; i := 1; nofnames := 0; w := defW; h := defH;
-  lang := defLang;
+  lang := '';
   WHILE i <= Args.Count DO Args.Get(i, s);
   WHILE i <= Args.Count DO Args.Get(i, s);
     IF s = '--window' THEN fs := FALSE
     IF s = '--window' THEN fs := FALSE
     ELSIF s = '--software' THEN sw := TRUE
     ELSIF s = '--software' THEN sw := TRUE
@@ -929,7 +937,7 @@ BEGIN fs := TRUE; sw := FALSE; i := 1; nofnames := 0; w := defW; h := defH;
         INC(i); Args.Get(i, lang);
         INC(i); Args.Get(i, lang);
         IF ~FoStrings.LangExists(lang) THEN Out.String('Language "');
         IF ~FoStrings.LangExists(lang) THEN Out.String('Language "');
           Out.String(lang); Out.String('" does not exist.'); Out.Ln;
           Out.String(lang); Out.String('" does not exist.'); Out.Ln;
-          lang := defLang
+          lang := ''
         END
         END
       END
       END
     ELSIF nofnames < LEN(fnames) THEN
     ELSIF nofnames < LEN(fnames) THEN
@@ -940,7 +948,8 @@ BEGIN fs := TRUE; sw := FALSE; i := 1; nofnames := 0; w := defW; h := defH;
     END;
     END;
     INC(i)
     INC(i)
   END;
   END;
-  IF nofnames < LEN(fnames) THEN fnames[nofnames][0] := 0X END
+  IF nofnames < LEN(fnames) THEN fnames[nofnames][0] := 0X END;
+  IF lang = '' THEN IdentifyLanguage(lang) END
 END ParseArgs;
 END ParseArgs;
 
 
 PROCEDURE Init(): BOOLEAN;
 PROCEDURE Init(): BOOLEAN;