home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / parser / lingua / lingua.doc < prev    next >
Encoding:
Text File  |  1992-07-31  |  6.6 KB  |  183 lines

  1. -- LINGUA -- MULTILANGUAGE SUPPORT FOR YOUR PROGRAMS -- SHAREWARE --
  2.  
  3. The LINGUA package is designed to help C-programmers to develop applications
  4. that must be released in multiple languages. The end user gets a program
  5. plus one or more datafiles containing all text in the program. One
  6. datafile for each different language. A language can be chosen at
  7. run time. This thus avoids different .exe files for different languages.
  8. The programmer needs only to compile one executable and to make a text data
  9. file for every supported language. It's also easy to afterwards create
  10. support for yet another language and send the data file to interested
  11. customers.
  12.  
  13.  
  14. HOW IT WORKS
  15.  
  16. The package consists of a program, LINGUA, and a module, UI_TEXT (UI
  17. stands for User Interface). The module should be compiled and linked with
  18. your application program. This module is the same for any language and
  19. is very small (about 2KB). For every supported language a text file is
  20. prepared by the programmer according to a specified format. This text
  21. file is then encrypted by LINGUA, so users cannot alter and perhaps corrupt
  22. it just by editing it. These encrypted text files are shipped with
  23. the application and one of them is loaded by the module UI_TEXT at run
  24. time so the application speaks the desired language.
  25.  
  26.  
  27. FILES IN THE PACKAGE
  28.  
  29. LINGUA.DOC        You're reading it
  30. LINGUA.EXE        Utility to encrypt .TXT file to .ETF file
  31. LINGUA.C          Source of the above
  32. UI_TEXT.OBJ       Module to be linked with your application (small model)
  33. UI_TEXT.C         Source of the above
  34. LINGDEMO.EXE      Small demo program, usage e.g.: lingdemo francais
  35. LINGDEMO.C        Source of the above
  36. ENGLISH.TXT       Text files for demo program
  37. FRANCAIS.TXT
  38. DEUTSCH.TXT
  39. NL.TXT
  40. ENGLISH.ETF       Encrypted files for demo program
  41. DEUTSCH.ETF
  42. FRANCAIS.ETF
  43. NL.ETF
  44. UI_TEXT.H         Header file created by LINGUA from .txt files above
  45.  
  46.  
  47. USAGE
  48.  
  49. First of all, do not use ANY literal strings in your C-source, but
  50. always use identifiers, e.g. not "Press any key" but ANYKEY.
  51. Write your program in any way you like while observing this main rule.
  52.  
  53. At the same time create and maintain a text file with all literal
  54. text for the program in your native language. This file may have any
  55. name but its extension should be .TXT for use by LINGUA. The lines in
  56. this text file should all begin (at the first position!) with an identifier,
  57. corresponding to the identifiers used in the program. Behind the identifier
  58. follows the literal string that should be used in run time. Comment lines
  59. are allowed, they must begin with #. In the literal strings _ signifies
  60. a leading or trailing space, and - denotes an empty string. String arrays,
  61. in which not every item has its own name, are represented by [ after an
  62. identifier's name followed by one or more lines starting with only [.
  63.  
  64. Example file english.txt:
  65.  
  66. #english.txt
  67. #empty string
  68. ZEROTH     -
  69. #normal strings
  70. FIRST     one
  71. SECOND    two times
  72. #array of five items
  73. THIRD[    three
  74. [         four
  75. [         five
  76. [         -
  77. [         seven
  78. #leading and trailing spaces
  79. EIGHTH    __eight__
  80. #that's it!
  81. NINTH     nine
  82.  
  83. Whenever any identifier in this text file has been added/edited/deleted,
  84. run the utility LINGUA, like:
  85.  
  86. lingua english
  87.  
  88. and recompile (like you would also have to do if you had edited
  89. literal strings in your source code).
  90.  
  91. LINGUA creates two files: english.etf and ui_text.h (ETF stands for
  92. Encrypted Text File). The header file UI_TEXT.H must be included in the
  93. source file that takes care of the loading and unloading of the text
  94. at run time. Since this header is not language dependent, no
  95. recompilation for another language is necessary. It contains only
  96. defines for all identifiers as show below.
  97.  
  98. Example file ui_text.h:
  99.  
  100. /* UI_TEXT.H */
  101.  
  102. void ui_loadtext(char *fname,char *vers);
  103. void ui_unloadtext(void);
  104. extern char **ui_text;
  105.  
  106. #define ZEROTH                         ui_text[0]
  107. #define FIRST                          ui_text[1]
  108. #define SECOND                         ui_text[2]
  109. #define THIRD                          (ui_text+3)
  110. #define EIGHTH                         ui_text[8]
  111. #define NINTH                          ui_text[9]
  112.  
  113. When your application is finished, make a copy of the original .TXT
  114. file and change the literal strings in the copy to another language.
  115. Be careful not to change the identifiers at the start of every line though!
  116. When you run LINGUA on this text file a new .ETF file is created
  117. (and also a ui_text.h, but this one is identical to the one in the
  118. original language).
  119.  
  120. In the application program, start with a call to ui_loadtext (in
  121. the UI_TEXT module). End the application program with a call to
  122. ui_unloadtext. Another language may be loaded at that point too.
  123.  
  124. Example file lingdemo.c (link with ui_text.c):
  125.  
  126. #include <stdio.h>
  127. #include "ui_text.h"
  128.  
  129. int main(int argc,char *argv[])
  130. {
  131.    char filename[81],version[81];
  132.  
  133.    if (argc>3) return 1;
  134.    if (argc==3) strcpy(version,argv[2]); else version[0]='\0';
  135.    if (argc>=2) strcpy(filename,argv[1]); else strcpy(filename,"english");
  136.  
  137.    ui_loadtext(filename,version);
  138.    printf("%s%s%s%s%s%s%s%s%s",
  139.           FIRST,SECOND,
  140.           THIRD[0],THIRD[1],THIRD[2],THIRD[3],THIRD[4],
  141.           EIGHTH,NINTH);
  142.    ui_unloadtext();
  143.    return 0;
  144. }
  145.  
  146. Execute this example program by:
  147.  
  148. lingdemo <name of etf-file without extension>
  149.  
  150. e.g.:
  151.  
  152. lingdemo english
  153.  
  154. If so desired an optional version number (or other string) may be
  155. given as second argument for the LINGUA utility. This same version
  156. number should then be used as the second parameter in the call
  157. to ui_loadtext. This can be useful to let ui_loadtext reject a file
  158. from a previous version of your application program.
  159.  
  160.  
  161. SHAREWARE NOTICE
  162.  
  163. You may copy and distribute this program freely, as long as all parts
  164. of the package are included without modification.  This is a shareware
  165. (NOT public domain) package; if you like it and use it on a regular
  166. basis please register it. Registration can be done at no charge by
  167. sending me a picture postcard from were you live or work. Suggestions
  168. for improvement are welcomed any time. Please do NOT modify the source
  169. code and pass that on. Send modified source code to me and I will
  170. include your modification, if I consider it useful, in a future release.
  171.  
  172. COMMERCIAL USERS -MUST- REGISTER AND SHOULD MENTION THE USE OF LINGUA
  173. IN THEIR DOCUMENTATION: LINGUA (C) SICHEMSOFT, WAGENINGEN, NETHERLANDS.
  174.  
  175. I hope many people, programmers and users alike, will benefit from LINGUA!
  176.  
  177. Anneke Sicherer-Roetman
  178. Roghorst 160
  179. 6708 KS Wageningen
  180. Netherlands
  181. email: anneke@ruucv1.chem.ruu.nl
  182.        anneke@hutruu54.bitnet
  183.