add notes on i18n
[platform/upstream/gstreamer.git] / docs / random / i18n
1 Internationalization notes
2 --------------------------
3 - apps:
4   - use setlocale to parse locale env vars and set to language code
5   - use textdomain to set the text domain of their app
6   - use bindtextdomain to tie the domain to a locale dir
7   - use gettext (possibly disguised as _) to translate in the current domain
8
9 - libraries:
10   - should only use bindtextdomain to tie a domain to a locale dir
11   - use dgettext (possibly disguised as _) to translate from a set domain
12
13 - How to make your plug-in code translateable:
14   - include <gst/gst-i18n-plugin.h> in all files that mark strings for
15     translation, or do the bindtextdomain call
16   - in plugin_init, add a block like this:
17
18 #ifdef ENABLE_NLS
19   GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
20       LOCALEDIR);
21   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
22 #endif /* ENABLE_NLS */
23
24   - mark all strings you want translated for translation by wrapping them in
25     _()
26   - typically, these are all strings that serve as the message string for a
27     GST_ELEMENT_ERROR or _WARNING
28   - but it could also consist of any strings that may end up being presented
29     to the user (for example mixer track)
30
31 Things to watch out for
32 -----------------------
33 - forgetting to bindtextdomain is an error that is not always noticeable,
34   because:
35   - any plugin from the same module being init'd binds the text domain,
36     so you may forget it in B, and still have it work because A bound the
37     domain
38   - without a bindtextdomain call, any domain is bound to the system locale
39     dir - so you could still have translations if it happens to be where the
40     translations are