VgaGames 3 - Multilanguage man-pages

[.. upper level ..]

Multilanguage functions

Support for multilanguage by storing text for serveral languages into text files.


Example

  /* Print entries from multilanguage files */

  

test1.mlang

[test1-entry1] en: Go to the left de: Gehe nach links [test1-entry2] en: This are$two lines de: Dies sind$zwei Zeilen

test2.mlang

[test2-entry1] en: Goodbye de: Auf Wiedersehen

main.c

struct vg3_multilang *mlang; const char *cptr; /* create multilanguage structure */ mlang = VG3_multilang_new(NULL, "en"); /* add entries from test1.mlang */ if (!VG3_multilang_add(mlang, "test1.mlang")) { fprintf(stderr, "test1.mlang not found\n"); exit(1); } /* add entries from test2.mlang */ if (!VG3_multilang_add(mlang, "test2.mlang")) { fprintf(stderr, "test2.mlang not found\n"); exit(1); } /* show entries of mlang1 */ cptr = VG3_multilang_get(mlang, "test1-entry1"); printf("entry1 of test1.mlang: %s\n", cptr); cptr = VG3_multilang_get(mlang, "test1-entry2"); printf("entry2 of test1.mlang: %s\n", cptr); /* show entries of mlang2 */ cptr = VG3_multilang_get(mlang, "test2-entry1"); printf("entry1 of test2.mlang: %s\n", cptr); cptr = VG3_multilang_get(mlang, "test2-entry2"); /* does not exist, uses key */ printf("entry2 of test2.mlang: %s\n", cptr); /* destroy multilanguage structure */ VG3_multilang_free(mlang);