summaryrefslogtreecommitdiff
path: root/gettext-tools/doc/lang-c.texi
blob: dc00fa0f57978df0ac7eb9d3db1fb3e1930f14af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@c This file is part of the GNU gettext manual.
@c Copyright (C) 1995-2020 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.

@node C
@subsection C, C++, Objective C
@cindex C and C-like languages

@table @asis
@item RPMs
gcc, gpp, gobjc, glibc, gettext

@item Ubuntu packages
gcc, g++, gobjc, libc6-dev, libasprintf-dev

@item File extension
For C: @code{c}, @code{h}.
@*For C++: @code{C}, @code{c++}, @code{cc}, @code{cxx}, @code{cpp}, @code{hpp}.
@*For Objective C: @code{m}.

@item String syntax
@code{"abc"}

@item gettext shorthand
@code{_("abc")}

@item gettext/ngettext functions
@code{gettext}, @code{dgettext}, @code{dcgettext}, @code{ngettext},
@code{dngettext}, @code{dcngettext}

@item textdomain
@code{textdomain} function

@item bindtextdomain
@code{bindtextdomain} and @code{wbindtextdomain} functions

@item setlocale
Programmer must call @code{setlocale (LC_ALL, "")}

@item Prerequisite
@code{#include <libintl.h>}
@*@code{#include <locale.h>}
@*@code{#define _(string) gettext (string)}

@item Use or emulate GNU gettext
Use

@item Extractor
@code{xgettext -k_}

@item Formatting with positions
@code{fprintf "%2$d %1$d"}
@*In C++: @code{autosprintf "%2$d %1$d"}
(@pxref{Top, , Introduction, autosprintf, GNU autosprintf})

@item Portability
autoconf (gettext.m4) and #if ENABLE_NLS

@item po-mode marking
yes
@end table

The following examples are available in the @file{examples} directory:
@code{hello-c}, @code{hello-c-gnome}, @code{hello-c++}, @code{hello-c++-qt}, 
@code{hello-c++-kde}, @code{hello-c++-gnome}, @code{hello-c++-wxwidgets},
@code{hello-objc}, @code{hello-objc-gnustep}, @code{hello-objc-gnome}.