home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / c2local / example / example.doc < prev    next >
Text File  |  1977-12-31  |  2KB  |  92 lines

  1.  
  2. This example shows how to localize the well known Hello-world program.
  3. In this example the text "This is a short text!" shall be replaced by
  4. "Dies ist ein langer Text, der eine neue Maximallänge erfordert."
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10.  
  11. char *p="This is a short text!";
  12.  
  13. main()
  14. {
  15.    puts("Hello world!");
  16.    puts(p);
  17. }
  18.  
  19.  
  20. First you have to add a call to InitStrings() in the beginnig of the main()
  21. function. To be able to compile this program just as a normal C-program as
  22. well, this call should be surrounded by #ifdef and #endif.
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26.  
  27. char *p="This is a short text";
  28.  
  29. main()
  30. {
  31. #ifdef __LOCALIZED
  32.    InitStrings();
  33. #endif
  34.    puts("Hello world!");
  35.    puts(p);
  36. }
  37.  
  38.  
  39. Now you use c2local to patch the sourcecode:
  40. c2local patch hello.c name hello
  41.  
  42.  
  43. Since the length of the german text is longer than the automatically
  44. reserved length, you must edit the stringfile.
  45.  
  46. ed hello_locale.str:
  47.  
  48. msg_0 "This is a short text!" 63
  49.  
  50.  
  51. Now compile the stringfile:
  52.  
  53. c2local compile name hello version 1 catalog hello.catalog
  54.  
  55.  
  56. Then compile the localized program:
  57.  
  58. cd localized
  59. sc #?.c link
  60.  
  61. After this you will have to translate the English texts. In this example
  62. into german. (Do not forget to sepcify the language via
  63. "##language deutsch"):
  64.  
  65. copy hello_locale.ct hello_deutsch.ct
  66. ed hello_deutsch.ct
  67.  
  68.  
  69. And then create the suitable catalog-directory and generate the catalog.
  70.  
  71. makedir catalogs
  72. makedir catalogs/deutsch
  73.  
  74. ccomp hello_locale.cd hello_deutsch.ct catalogs/deutsch/hello.catalog
  75.  
  76. That's it. (The makelocal-script does exactly the above,)
  77.  
  78.  
  79. If the program fails to use the german language, although you have selected
  80. it via prefs, check the following:
  81. - is the catalog in the correct directory ?
  82. - is the name of the catalog correct ?
  83. - does the versionnumber of the catalog match that one selected in the
  84.   program ?
  85. - did you specify the language in the .ct-file ?
  86. - is there an old catalog within the memory (-> "avail flush") ?
  87.  
  88.  
  89.  
  90.  
  91.  
  92.