Browse Source

+ Initial implementation of resourcestrings test example

michael 26 years ago
parent
commit
5149a533f1

+ 5 - 2
fcl/tests/Makefile

@@ -37,7 +37,7 @@ NEEDOPT=-S2
 UNITOBJECTS=
 UNITOBJECTS=
 EXEOBJECTS=stringl dparser fstream mstream list threads testrtf\
 EXEOBJECTS=stringl dparser fstream mstream list threads testrtf\
            cfgtest testz testz2 xmldump htdump testcgi tidea\
            cfgtest testz testz2 xmldump htdump testcgi tidea\
-           b64test b64test2 b64enc b64dec
+           b64test b64test2 b64enc b64dec restest
 
 
 
 
 #####################################################################
 #####################################################################
@@ -114,7 +114,10 @@ endif
 
 
 #
 #
 # $Log$
 # $Log$
-# Revision 1.11  1999-08-09 16:12:26  michael
+# Revision 1.12  1999-08-27 15:52:29  michael
+# + Initial implementation of resourcestrings test example
+#
+# Revision 1.11  1999/08/09 16:12:26  michael
 # * Fixes and new examples from Sebastian Guenther
 # * Fixes and new examples from Sebastian Guenther
 #
 #
 # Revision 1.10  1999/08/03 17:02:36  michael
 # Revision 1.10  1999/08/03 17:02:36  michael

+ 2 - 0
fcl/tests/README

@@ -32,3 +32,5 @@ b64test.pp   test program for base64 encoding streams (SG)
 b64test2.pp  test program for base64 encoding streams (SG)
 b64test2.pp  test program for base64 encoding streams (SG)
 b64enc.pp    base64-encodes StdIn to StdOut (SG)
 b64enc.pp    base64-encodes StdIn to StdOut (SG)
 b64dec.pp    base64-decodes StdIn to StdOut (SG)
 b64dec.pp    base64-decodes StdIn to StdOut (SG)
+restest.pp   test program for resourcestrings with GNU gettext. (MVC)
+             (see also intl subdirectory)

+ 20 - 0
fcl/tests/intl/Makefile

@@ -0,0 +1,20 @@
+#
+# Makefile to make the internationalization files for the resstr example
+# Add a 2 letter code when adding a language to DEMOLANGUAGES
+#
+
+DEMOLANGUAGES=fr nl
+
+#
+# No need to add after this line.
+#
+
+OBJECTS=$(addprefix restest.,$(DEMOLANGUAGES))
+MOOBJECTS=$(addsuffix .mo,$(OBJECTS))
+
+.SUFFIXES: .mo .po
+
+%.mo: %.po
+	msgfmt -o $@ $?
+
+all: $(MOOBJECTS)

+ 45 - 0
fcl/tests/intl/README

@@ -0,0 +1,45 @@
+How to add a new language:
+
+You have to know your language code. Currently, the gettext unit simply takes
+the first and second character of the environment variable $LANG.
+Examples for this 2-char language codes are
+  de  for German
+  en  for English
+  fr  for Frensh
+
+you can check the currently selected language with the command
+  echo $LANG
+
+change this value using 
+(in bash)
+  export LANG=<langcode>
+(in csh)
+  setenv LANG <langcode>
+
+Then, make a copy of the file "restest.po", call the copy
+  restest.<langcode>.po 
+(Insert your language code for <langcode>)
+ 
+After this you can edit the created .po file using your favorite editor.
+For each string, there is an "msgid" and an "msgstr" entry. msgid is the
+original string, don't change its value. Just add the translated string to
+the "msgstr" line. Please translate the strings carefully, especially some
+special characters like "%" inserts or quotation marks have to be at exactly
+the same semantic position as in the original string.
+
+When you are finished with your translation, add the language code to
+the variable DEMOLANGUAGES in the Makefile and do a 'make'. If all goes
+well, a file
+  restest.<langcode>.mo
+will be created. This file will be loaded by the restest example program.
+if there weren't any errors in your input file, you're finished.
+
+If you don't have 'make', you can make the .mo file with the following
+command:
+
+msgfmt -o restest.<langcode>.mo restest.<langcode>.po
+
+If you add a new language, please send the .po file to the Free Pascal
+developers.
+
+Michael. <[email protected]>

BIN
fcl/tests/intl/restest.fr.mo


+ 16 - 0
fcl/tests/intl/restest.fr.po

@@ -0,0 +1,16 @@
+#: testo:testing
+msgid "Testing :"
+msgstr "Testons:"
+
+#: testo:first
+msgid "First"
+msgstr "Première"
+
+#: testo:second
+msgid "Second"
+msgstr "Deuxième"
+
+#: testo:third
+msgid "Third"
+msgstr "Troisième"
+

BIN
fcl/tests/intl/restest.nl.mo


+ 12 - 0
fcl/tests/intl/restest.nl.po

@@ -0,0 +1,12 @@
+#: testo:first
+msgid "First"
+msgstr "Eerste"
+
+#: testo:second
+msgid "Second"
+msgstr "Tweede"
+
+#: testo:third
+msgid "Third"
+msgstr "Derde"
+

+ 16 - 0
fcl/tests/intl/resttest.po

@@ -0,0 +1,16 @@
+#: testo:testing
+msgid "Testing :"
+msgstr "Aan het testen :"
+
+#: testo:first
+msgid "First"
+msgstr "Eerste"
+
+#: testo:second
+msgid "Second"
+msgstr "Tweede"
+
+#: testo:third
+msgid "Third"
+msgstr "Derde"
+

+ 25 - 0
fcl/tests/restest.pp

@@ -0,0 +1,25 @@
+Program Restest;
+
+{$mode delphi}
+{$h+}
+
+uses gettext;
+
+resourcestring
+
+  Testing = 'Testing :';
+  First = 'First';
+  Second = 'Second';
+  Third = 'Third';
+  
+begin 
+  { Tell gettext to translate the strings 
+    according to the settings in the LANG environment variable 
+    remark that the program must be run in the tests directory
+    where the intl subdirectory exists }
+  TranslateResourcestrings('intl/restest.%s.mo');
+  Writeln(Testing);
+  Writeln(First);
+  Writeln(Second);
+  Writeln(Third);
+end.