home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / LINGU11A / LINGUA.DOC < prev    next >
Text File  |  1993-03-14  |  8KB  |  209 lines

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