Multilanguage functions
Support for multilanguage by storing text for serveral languages into text files.
- Structures and Enumerations
- Creating and destroying
- VG3_multilang_new()
Return an initialized empty multilanguage structure. - VG3_multilang_free()
Destroy a multilanguage structure. - Using multilanguage
- VG3_multilang_clear()
Clear a multilanguage structure. - VG3_multilang_add()
Add texts from a file into a multilanguage structure. - VG3_multilang_get()
Return a text of the given language by a key. - VG3_multilang_locale()
Return locale.
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 Zeilentest2.mlang
[test2-entry1] en: Goodbye de: Auf Wiedersehenmain.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);