[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] kedit: Mehrsprachige Strings



+ kedit: Englischsprachige Strings
* kedit: Versionsnummer aus der Menueleiste unten entfernt, dafuer
  Hinweis auf Syntaxhighlighting mit F8 eingefuegt.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/pas/kedit/Makefile.all       |    2 +-
 src/modules/pas/kedit/kedit.pas          |   17 ++++++-
 src/modules/pas/kedit/kedit_input.pas    |    8 ++-
 src/modules/pas/kedit/kedit_main.pas     |   28 +++++++---
 src/modules/pas/kedit/kedit_tui.pas      |    8 ++-
 src/modules/pas/kedit/lang/Makefile.conf |    1 +
 src/modules/pas/kedit/lang/lang_en.c     |   79 ++++++++++++++++++++++++++++++
 src/modules/pas/kedit/lang/resstr.h      |   40 +++++++++++++++
 8 files changed, 168 insertions(+), 15 deletions(-)
 create mode 100644 src/modules/pas/kedit/lang/Makefile.conf
 create mode 100644 src/modules/pas/kedit/lang/lang_en.c
 create mode 100644 src/modules/pas/kedit/lang/resstr.h

diff --git a/src/modules/pas/kedit/Makefile.all b/src/modules/pas/kedit/Makefile.all
index f3697e4..7f4d2d0 100644
--- a/src/modules/pas/kedit/Makefile.all
+++ b/src/modules/pas/kedit/Makefile.all
@@ -1,4 +1,4 @@
 shopt -s extglob
 echo "LD   $1/kedit"
-"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name`
+"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name`
 strip -s kedit -o $1/apps/kedit
diff --git a/src/modules/pas/kedit/kedit.pas b/src/modules/pas/kedit/kedit.pas
index 54ea9d8..992bd0e 100644
--- a/src/modules/pas/kedit/kedit.pas
+++ b/src/modules/pas/kedit/kedit.pas
@@ -2,7 +2,7 @@ program KEdit;
 {$H+}
 
 uses
-    crt, sysutils, tyndur,
+    dos, crt, sysutils, tyndur, multilang,
     kedit_tui, kedit_buf, kedit_input, kedit_main;
 
 type
@@ -227,10 +227,25 @@ begin
     until exitEditor;
 end;
 
+procedure SetLang;
+var
+    name: String;
+    lang: TLanguage;
+begin
+    name := GetEnv('LANG');
+    if name <> '' then begin
+        lang := GetLanguage(name);
+        if lang <> nil then begin
+            SetLanguage(lang);
+        end;
+    end;
+end;
+
 var
     i: integer;
 begin
     DisableFlushing(output);
+    SetLang;
 
     New(state.text);
     for i:=1 to ParamCount do begin
diff --git a/src/modules/pas/kedit/kedit_input.pas b/src/modules/pas/kedit/kedit_input.pas
index 493d6b8..2d4f33a 100644
--- a/src/modules/pas/kedit/kedit_input.pas
+++ b/src/modules/pas/kedit/kedit_input.pas
@@ -17,6 +17,10 @@ implementation
 
 uses sysutils, crt, kedit_buf;
 
+resourcestring
+    rsFileNotSaved = 'Die Datei ist noch nicht gespeichert. Speichern?';
+
+
 procedure uih_save_file(state: pkedit_state);
 begin
     if state^.readonly then begin
@@ -30,7 +34,7 @@ end;
 
 procedure uih_load_file(state: pkedit_state);
 begin
-    if changed then case YesNoCancel('Die Datei ist noch nicht gespeichert. Speichern?', true) of
+    if changed then case YesNoCancel(rsFileNotSaved, true) of
         OPT_YES:    SaveFile(state);
         OPT_NO:     changed := false;
         OPT_CANCEL: {do nothing};
@@ -52,7 +56,7 @@ end;
 
 procedure uih_quit(state: pkedit_state);
 begin
-    if changed then case YesNoCancel('Die Datei ist noch nicht gespeichert. Speichern?', true) of
+    if changed then case YesNoCancel(rsFileNotSaved, true) of
         OPT_YES:    SaveFile(state);
         OPT_NO:     changed := false;
         OPT_CANCEL: {do nothing};
diff --git a/src/modules/pas/kedit/kedit_main.pas b/src/modules/pas/kedit/kedit_main.pas
index a62f794..a2714e0 100644
--- a/src/modules/pas/kedit/kedit_main.pas
+++ b/src/modules/pas/kedit/kedit_main.pas
@@ -45,6 +45,12 @@ implementation
 uses crt, dos, sysutils, strutils, kedit_tui;
 
 
+resourcestring
+    rsFilename = 'Dateiname';
+    rsFileIsReadOnly = 'Die Datei %s existiert und ist schreibgeschützt. [ENTER]';
+    rsOverwriteExistingFile = 'Die Datei %s gibt''s schon. Ã?berschreiben?';
+    rsFileNotFound = 'Datei %s nicht gefunden.';
+
 
 function RTrim(stext: string):string;
 begin
@@ -93,16 +99,15 @@ begin
         TextBackground(1);
 
         // Dateinamen abfragen
+        GotoXY(1,1);
+        Write(space(79));
         if filename='(unbenannt)' then begin
             GotoXY(1,1);
-            Write('Dateiname:'+Space(69));
-            GotoXY(12,1);
+            Write(rsFilename, ': ');
             ReadLn(savename);
         end else begin
             GotoXY(1,1);
-            Write(space(79));
-            GotoXY(1,1);
-            Write('Dateiname [',filename,']: ');
+            Write(rsFilename, ' [',filename,']: ');
             ReadLn(savename);
             if savename='' then begin
                 savename := filename;
@@ -122,12 +127,12 @@ begin
             GotoXY(1,1);
 
             if attr and dos.ReadOnly = dos.Readonly then begin
-                Write('Die Datei ',savename,' existiert und ist schreibgeschützt. [ENTER]');
+                Write(Format(rsFileIsReadOnly, [savename]));
                 Textbackground(0);
                 readkey;
                 exit;
             end else begin
-                case YesNoCancel('Die Datei ' + savename + ' gibt''s schon. Ã?berschreiben?', false) of
+                case YesNoCancel(Format(rsOverwriteExistingFile, [savename]), false) of
                     OPT_YES:    {Do nothing};
                     OPT_NO:     exit;
                 end;
@@ -173,7 +178,7 @@ begin
     if loadname = '' then begin
         Textbackground(1);
         gotoxy(1,1); Write(space(79));
-        gotoxy(1,1); Write('Zu ladende Datei: '); ReadLn(loadname);
+        gotoxy(1,1); Write(rsFilename, ': '); ReadLn(loadname);
         Textbackground(0);
     end;
 
@@ -190,8 +195,13 @@ begin
             exit;
         end else begin
             gotoxy(1,1); Write(space(79));
-            gotoxy(1,1); Textbackground(4); Write('Datei ', loadname, ' nicht gefunden.'); Textbackground(0);
+
+            gotoxy(1,1);
+            Textbackground(4);
+            Write(Format(rsFileNotFound, [loadname]));
+            Textbackground(0);
             readkey;
+
             gotoxy(1,1); Write(space(79));
             exit;
         end;
diff --git a/src/modules/pas/kedit/kedit_tui.pas b/src/modules/pas/kedit/kedit_tui.pas
index 5b767ba..14a56b4 100644
--- a/src/modules/pas/kedit/kedit_tui.pas
+++ b/src/modules/pas/kedit/kedit_tui.pas
@@ -35,6 +35,10 @@ uses
     crt, strutils, sysutils,
     syntax, syntax_c, syntax_pas, syntax_intel, syntax_atandt;
 
+resourcestring
+    rsMenuBar = 'F2: Speichern, F3: Laden, F8: Syntax, F10: Beenden, EINFG: Einfügen/Ersetzen';
+    rsMenuBarReadOnly = 'F2: R/W laden, F3: Laden, F8: Syntax, F10: Beenden, EINFG: Einfügen/Ersetzen';
+
 var
     highlighter: TSyntax;
 
@@ -266,9 +270,9 @@ begin
     TextBackground(1);
     TextColor(7);
     if state^.readonly then begin
-        Write('F2: R/W laden, F3: Laden, F10: Beenden, EINFG: Einfügen/Ersetzen    ['+Version+']'#27'[K');
+        Write(rsMenuBarReadOnly, #27'[K');
     end else begin
-        Write('F2: Speichern, F3: Laden, F10: Beenden, EINFG: Einfügen/Ersetzen    ['+Version+']'#27'[K');
+        Write(rsMenuBar, #27'[K');
     end;
 
     // Cursor richtig in den Text setzen
diff --git a/src/modules/pas/kedit/lang/Makefile.conf b/src/modules/pas/kedit/lang/Makefile.conf
new file mode 100644
index 0000000..594ef2a
--- /dev/null
+++ b/src/modules/pas/kedit/lang/Makefile.conf
@@ -0,0 +1 @@
+CC_FLAGS_APPEND="-Wno-missing-braces"
diff --git a/src/modules/pas/kedit/lang/lang_en.c b/src/modules/pas/kedit/lang/lang_en.c
new file mode 100644
index 0000000..9712ec8
--- /dev/null
+++ b/src/modules/pas/kedit/lang/lang_en.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Kevin Wolf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <tms.h>
+#include "resstr.h"
+
+static int get_number(int n)
+{
+    return (n == 1 ? 0 : 1);
+}
+
+static const struct tms_strings dict[] = {
+    // Die Datei ist noch nicht gespeichert. Speichern?
+    &RESSTR_KEDIT_INPUT_RSFILENOTSAVED,
+    "The file has not been saved yet. Save it now?",
+
+    // Dateiname
+    &RESSTR_KEDIT_MAIN_RSFILENAME,
+    "File name",
+
+    // Die Datei %s existiert und ist schreibgeschützt
+    &RESSTR_KEDIT_MAIN_RSFILEISREADONLY,
+    "The file %s exists already and is write protected",
+
+    // Die Datei %s gibt's schon. Ã?berschreiben?
+    &RESSTR_KEDIT_MAIN_RSOVERWRITEEXISTINGFILE,
+    "The file %s exists already. Overwrite it?",
+
+    // Datei %s nicht gefunden.
+    &RESSTR_KEDIT_MAIN_RSFILENOTFOUND,
+    "File %s could not be found.",
+
+    // F2: Speichern, F3: Laden, F8: Syntax, F10: Beenden,
+    // EINFG: Einfügen/Ersetzen
+    &RESSTR_KEDIT_TUI_RSMENUBAR,
+    "F2: Save, F3: Load, F8: Syntax, F10: Exit; INS: Insert/Replace",
+
+    // F2: R/W laden, F3: Laden, F8: Syntax, F10: Beenden,
+    // EINFG: Einf'#195#188'gen/Ersetzen
+    &RESSTR_KEDIT_TUI_RSMENUBARREADONLY,
+    "F2: Open R/W, F3: Load, F8: Syntax, F10: Exit; INS: Insert/Replace",
+
+    0,
+    0,
+};
+
+static const struct tms_lang lang = {
+    .lang = "en",
+    .numbers = 2,
+    .get_number = get_number,
+    .strings = dict,
+};
+
+LANGUAGE(&lang)
diff --git a/src/modules/pas/kedit/lang/resstr.h b/src/modules/pas/kedit/lang/resstr.h
new file mode 100644
index 0000000..1c0c61b
--- /dev/null
+++ b/src/modules/pas/kedit/lang/resstr.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Kevin Wolf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL;
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO;
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY;
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RESSTR_H
+#define RESSTR_H
+
+extern void* RESSTR_KEDIT_INPUT_RSFILENOTSAVED;
+extern void* RESSTR_KEDIT_MAIN_RSFILENAME;
+extern void* RESSTR_KEDIT_MAIN_RSFILEISREADONLY;
+extern void* RESSTR_KEDIT_MAIN_RSOVERWRITEEXISTINGFILE;
+extern void* RESSTR_KEDIT_MAIN_RSFILENOTFOUND;
+extern void* RESSTR_KEDIT_TUI_RSMENUBAR;
+extern void* RESSTR_KEDIT_TUI_RSMENUBARREADONLY;
+
+#endif
-- 
1.6.0.2