Browse Source

More strings moved to en.dat

Arthur Yefimov 3 years ago
parent
commit
f84480ccea
4 changed files with 76 additions and 30 deletions
  1. 21 0
      Data/Texts/en.dat
  2. 16 10
      src/Editor.Mod
  3. 12 5
      src/FoStrings.Mod
  4. 27 15
      src/FreeOberon.Mod

+ 21 - 0
Data/Texts/en.dat

@@ -267,3 +267,24 @@ menuSave "Save"
 menuOpen "Open"
 menuCompileAndRun "Compile & Run"
 menuLocalMenu "Local menu"
+
+titleAbout "About"
+titleFreeOberon "Free Oberon"
+version "version"
+copyright "Copyright (c)"
+copyrightBy "by"
+authorName "Arthur Yefimov"
+
+btnOk "O&K"
+btnOpen "&Open"
+btnCancel "Cancel"
+
+titleSaveFileAs "Save File As"
+titleOpenAFile "Open a File"
+
+labelSaveFileAs "&Save file as"
+labelName "&Name"
+labelFiles "&Files"
+
+
+

+ 16 - 10
src/Editor.Mod

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
 along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *)
 IMPORT OV, T := TermBox, Text := EditorText,
-  Int, Strings, StrList, Dir, Out;
+  Int, Strings, FoStrings, StrList, Dir, Out;
 CONST
   stdPath* = 'Programs/';
   dotChar = 0B7X; (* To higlight spaces *)
@@ -120,7 +120,7 @@ PROCEDURE FileDialogApplyDir*(c: FileDialog; s: ARRAY OF CHAR);
 VAR i: INTEGER;
   path: ARRAY 1024 OF CHAR;
 BEGIN
-  IF (s[0] = '/') OR (* Asbolute path *)
+  IF (s[0] = '/') OR (* Absolute path *)
      ('A' <= CAP(s[0])) & (CAP(s[0]) <= 'Z') & (s[1] = ':')
   THEN path := s$
   ELSE path := c.path$;
@@ -211,9 +211,10 @@ END FileDialogListChange;
 
 PROCEDURE InitFileDialog*(c: FileDialog; type: INTEGER);
 VAR L: INTEGER;
+  s: FoStrings.String;
 BEGIN OV.InitWindow(c); c.do := fileDialogMethod; c.type := type;
-  IF type = open THEN c.caption := 'Open a File'
-  ELSE c.caption := 'Save File As'
+  IF type = open THEN FoStrings.Get('titleOpenAFile', c.caption)
+  ELSE FoStrings.Get('titleSaveFileAs', c.caption)
   END;
   c.modal := TRUE; c.w := 70; c.h := 20; OV.CenterWindow(c);
 
@@ -223,9 +224,10 @@ BEGIN OV.InitWindow(c); c.do := fileDialogMethod; c.type := type;
   OV.Add(c, c.edtFilename);
 
   (* Open/Save (Ok) button *)
-  IF type = open THEN c.btnOk := OV.NewButton('&Open')
-  ELSE c.btnOk := OV.NewButton('O&K')
+  IF type = open THEN FoStrings.Get('btnOpen', s)
+  ELSE FoStrings.Get('btnOk', s)
   END;
+  c.btnOk := OV.NewButton(s);
   c.btnOk.default := TRUE;
   c.btnOk.tabIndex := 2;
   c.btnOk.onClick := FileDialogOkClick;
@@ -233,7 +235,8 @@ BEGIN OV.InitWindow(c); c.do := fileDialogMethod; c.type := type;
   OV.Add(c, c.btnOk);
 
   (* Cancel button *)
-  c.btnCancel := OV.NewButton('Cancel');
+  FoStrings.Get('btnCancel', s);
+  c.btnCancel := OV.NewButton(s);
   c.btnCancel.tabIndex := 3;
   c.btnCancel.onClick := OV.CloseCurWindow;
   c.btnCancel.do.resize(c.btnCancel, c.w - 13, 11, 9, 1);
@@ -267,12 +270,15 @@ RETURN c END NewFileDialog;
 
 PROCEDURE FileDialogDraw*(c: OV.Control; x, y: INTEGER);
 VAR f: FileDialog;
+  s: FoStrings.String;
 BEGIN f := c(FileDialog);
   OV.WindowDraw(c, x, y); INC(x, c.x); INC(y, c.y);
-  IF f.type = open THEN OV.PutMarkedString(x + 3, y + 2, '&Name', 15, 14, 7, 0)
-  ELSE OV.PutMarkedString(x + 3, y + 2, '&Save file as', 15, 14, 7, 0)
+  IF f.type = open THEN FoStrings.Get('labelName', s)
+  ELSE FoStrings.Get('labelSaveFileAs', s)
   END;
-  OV.PutMarkedString(x + 3, y + 5, '&Files', 0, 14, 7, 0)
+  OV.PutMarkedString(x + 3, y + 2, s, 15, 14, 7, 0);
+  FoStrings.Get('labelFiles', s);
+  OV.PutMarkedString(x + 3, y + 5, s, 0, 14, 7, 0)
 END FileDialogDraw;
 
 PROCEDURE FileDialogGetFocus(c: OV.Control);

+ 12 - 5
src/FoStrings.Mod

@@ -2,13 +2,15 @@ MODULE FoStrings;
 IMPORT Strings, Texts, Int, Dir, Out;
 
 CONST
-  maxErrors = 500;
-  maxStrings = 2000;
+  maxErrors* = 500;
+  maxStrings* = 2000;
+  keyLen* = 128;
+  strLen* = 128;
 
-TYPE String = ARRAY 128 OF CHAR;
+TYPE String* = ARRAY strLen OF CHAR;
   Pair = RECORD
-    key: ARRAY 64 OF CHAR;
-    value: ARRAY 128 OF CHAR
+    key: ARRAY keyLen OF CHAR;
+    value: ARRAY strLen OF CHAR
   END;
 
 VAR lang: ARRAY 6 OF CHAR;
@@ -25,6 +27,11 @@ BEGIN i := 0;
   END
 END Get;
 
+PROCEDURE Append*(key: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
+VAR s: ARRAY strLen OF CHAR;
+BEGIN Get(key, s); Strings.Append(s, dest)
+END Append;
+
 PROCEDURE GetErrorStr*(err: INTEGER; VAR s: ARRAY OF CHAR);
 BEGIN
   IF (0 <= err) & (err < LEN(errorStr)) THEN Strings.Copy(errorStr[err], s)

+ 27 - 15
src/FreeOberon.Mod

@@ -20,6 +20,7 @@ IMPORT T := TermBox, Files, Args, Utf8,
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
 CONST
   version* = '1.1.0-alpha.1';
+  year = 2022;
 
   (* Direction of Selection *)
   dirLeft  = 0;
@@ -530,7 +531,7 @@ BEGIN
       END;
       Utf8.Decode(buf, z);
       ParseErrors(z, fname, line, col, error);
-      ;;;;;;;;Out.String('Место ошибки: '); Out.Int(line, 0);Out.Char(':');Out.Int(col, 0);Out.Ln;;;;;;;
+      (*;;;;;;;;Out.String('Место ошибки: '); Out.Int(line, 0);Out.Char(':');Out.Int(col, 0);Out.Ln;;;;;;;*)
       FocusOrOpenFile(fname);
       e := app.windows(Editor.Editor);
       IF (col = 1) & (line # 1) THEN
@@ -579,7 +580,8 @@ BEGIN sysModules := NIL;
   Add('In');      Add('Out');      Add('Math');   Add('MathL');
   Add('Modules'); Add('Platform'); Add('Oberon'); Add('Reals');
   Add('VT100');   Add('Graph');    Add('SDL2');   Add('Term');
-  Add('Dir');     Add('Int')
+  Add('Graph2');  Add('Allegro5'); Add('TermBox');
+  Add('Dir');     Add('Int');      Add('Random')
 END ResetSysModules;
 
 PROCEDURE CompileAll(modules: StrList; graph: BOOLEAN;
@@ -621,9 +623,8 @@ BEGIN dir := prg$;
   Utf8.Encode(dir, d);
   IF ~Term.StartProcessIn(s, d) THEN
     ;;;;;;;;;;Out.String('EXECUTION FAILED');Out.Ln;;;;;;;;;
-    T.Print(0, tH - 1, -1, ' Program execution failed ', 15, 4);
-    T.Flush
-    (* ; T.Pause !FIXME*)
+    (*T.Print(0, tH - 1, -1, ' Program execution failed ', 15, 4);
+    T.Flush; T.Pause !FIXME*)
   ELSE
     programFinished := FALSE;
     RunTerminal
@@ -815,7 +816,7 @@ BEGIN res := NIL; ok := TRUE;
       END
     ELSE
       Strings.Copy(fname, errFname);
-      Out.String('Не могу разобраться с '); Out.String(modname); Out.Ln
+      ;;;;;Out.String('Не могу разобраться с '); Out.String(modname); Out.Ln;;;;;
     END
   END;
   IF ok THEN
@@ -825,7 +826,7 @@ BEGIN res := NIL; ok := TRUE;
 RETURN res END UsedModuleList;
 
 PROCEDURE ImportsGraph(p: StrList): BOOLEAN;
-BEGIN WHILE (p # NIL) & (p.s # 'Graph') DO p := p.next END ;
+BEGIN WHILE (p # NIL) & (p.s # 'Graph') & (p.s # 'Graph2') (*!FIXME*) DO p := p.next END ;
 RETURN p # NIL END ImportsGraph;
 
 (* "Module.Mod" -> "Module" *)
@@ -878,28 +879,37 @@ END OnBuild;
 PROCEDURE HelpAbout(c: OV.Control);
 CONST W = 37; H = 13;
 VAR w: OV.Window; L: OV.Label; b: OV.Button;
-  s: ARRAY 40 OF CHAR;
+  s: FoStrings.String;
   Y: INTEGER;
   tW, tH: INTEGER;
-BEGIN w := OV.NewWindow(); w.modal := TRUE; w.caption := 'About';
+BEGIN w := OV.NewWindow(); w.modal := TRUE;
+  FoStrings.Get('titleAbout', w.caption);
   T.Size(tW, tH);
   w.do.resize(w, (tW - W) DIV 2, (tH - H) DIV 2, W, H);
   Y := 2;
 
-  L := OV.NewLabel('Free Oberon'); L.align := OV.center;
+  FoStrings.Get('titleFreeOberon', s);
+  L := OV.NewLabel(s); L.align := OV.center;
   L.do.resize(L, 1, Y, W - 2, 1); OV.Add(w, L); INC(Y, 2);
 
-  s := 'Version '; Strings.Append(version, s);
+  FoStrings.Get('version', s); Strings.Append(' ', s);
+  Strings.Append(version, s);
   L := OV.NewLabel(s); L.align := OV.center;
   L.do.resize(L, 1, Y, W - 2, 1); OV.Add(w, L); INC(Y, 2);
 
-  L := OV.NewLabel('Copyright (c) 2017-2022 by'); L.align := OV.center;
+  FoStrings.Get('copyright', s); Strings.Append(' 2017-', s);
+  Int.Append(year, s); Strings.Append(' ', s);
+  FoStrings.Append('copyrightBy', s);
+  
+  L := OV.NewLabel(s); L.align := OV.center;
   L.do.resize(L, 1, Y, W - 2, 1); OV.Add(w, L); INC(Y, 2);
 
-  L := OV.NewLabel('Arthur Yefimov, free.oberon.org'); L.align := OV.center;
+  FoStrings.Get('authorName', s); Strings.Append(', free.oberon.org', s);
+  L := OV.NewLabel(s); L.align := OV.center;
   L.do.resize(L, 1, Y, W - 2, 1); OV.Add(w, L); INC(Y, 2);
 
-  b := OV.NewButton('O&K'); b.default := TRUE;
+  FoStrings.Get('btnOk', s);
+  b := OV.NewButton(s); b.default := TRUE;
   b.do.resize(b, (W - 8) DIV 2, Y, 8, 1); OV.Add(w, b); INC(Y, 2);
   b.onClick := OV.CloseCurWindow;
 
@@ -1274,6 +1284,7 @@ PROCEDURE Init(): BOOLEAN;
 VAR success, fs, sw: BOOLEAN;
   w, h: INTEGER;
   lang: ARRAY 6 OF CHAR;
+  s: FoStrings.String;
   fnames: Fnames;
   opt: SET;
 BEGIN
@@ -1283,7 +1294,8 @@ BEGIN
   IF fs THEN INCL(opt, T.fullscreen) ELSE INCL(opt, T.window) END;
   T.Settings(w, h, opt);
   FoStrings.SetLang(lang);
-  T.SetTitle('Free Oberon');
+  FoStrings.Get('titleFreeOberon', s);
+  T.SetTitle(s);
   T.Init;
   IF T.Done THEN
     InitIDE;