### Example POTFILES.in File
Source: https://www.gnu.org/software/gettext/manual/html_node/po_002fPOTFILES_002ein.html
This example shows the format of the POTFILES.in file, listing source files that contain translatable strings. Lines starting with '#' and blank lines are ignored.
```plaintext
# List of source files containing translatable strings.
# Copyright (C) 1995 Free Software Foundation, Inc.
# Common library files
lib/error.c
lib/getopt.c
lib/xmalloc.c
# Package source files
src/gettext.c
src/msgfmt.c
src/xgettext.c
```
--------------------------------
### Install GNU gettext on Windows
Source: https://www.gnu.org/software/gettext/FAQ.html
Use DESTDIR to specify an installation directory when running 'make install'. This is useful for staging installations or custom directory structures.
```bash
make install DESTDIR=/some/tempdir
```
--------------------------------
### msgfmt Desktop Entry Mode Example
Source: https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html
Example of using msgfmt in Desktop Entry mode to generate a .desktop file for a single locale. The -o and --template options are mandatory.
```bash
msgfmt --desktop --template=template --locale=locale \
-o file filename.po ...
```
--------------------------------
### pgettext example for GUI menu items
Source: https://www.gnu.org/software/gettext/manual/html_node/Contexts.html
This example demonstrates using pgettext with menu paths as contexts to differentiate translations for menu items like 'Open'. The context string is the menu path leading to the item.
```c
pgettext ("Menu|File|Open", "Open")
```
```c
pgettext ("Menu|Printer|Open", "Open")
```
```c
pgettext ("Menu|", "File")
```
```c
pgettext ("Menu|", "Printer")
```
```c
pgettext ("Menu|File|", "Open")
```
```c
pgettext ("Menu|File|", "New")
```
```c
pgettext ("Menu|Printer|", "Select")
```
```c
pgettext ("Menu|Printer|", "Open")
```
```c
pgettext ("Menu|Printer|", "Connect")
```
--------------------------------
### msgfmt Desktop Entry Bulk Mode Example
Source: https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html
Example of using msgfmt in Desktop Entry mode for bulk processing of multiple .po files. It reads the LINGUAS file under the specified directory.
```bash
msgfmt --desktop --template=template -d directory -o file
```
--------------------------------
### Example PO File Entry with Plural Forms
Source: https://www.gnu.org/software/gettext/manual/html_node/Entries-with-Plural-Forms.html
Illustrates a concrete example of a PO file entry for a string with plural forms. Shows how to specify singular and plural message IDs and provide translations for the first two plural cases (case 0 and case 1).
```po
#: src/msgcmp.c:338 src/po-lex.c:699
#, c-format
msgid "found %d fatal error"
msgid_plural "found %d fatal errors"
msgstr[0] "s'ha trobat %d error fatal"
msgstr[1] "s'han trobat %d errors fatals"
```
--------------------------------
### Example PO File Entry
Source: https://www.gnu.org/software/gettext/manual/html_node/PO-File-Entries.html
A concrete example of a PO file entry, demonstrating the typical format with a source code reference, an untranslated string, and its corresponding translation.
```plaintext
#: lib/error.c:116
msgid "Unknown system error"
msgstr "Error desconegut del sistema"
```
--------------------------------
### xgettext Example Invocation
Source: https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html
This example shows a typical invocation of xgettext for a C project. It specifies the output file, adds translator comments, defines keywords and flags, sets the directory, and lists the source file.
```bash
xgettext -o hello.pot \
--add-comments=TRANSLATORS: \
--keyword=_ --flag=_:1:pass-c-format \
--directory=.. \
src/hello.c
```
--------------------------------
### Initialize a New PO File with msginit
Source: https://www.gnu.org/software/gettext/manual/html_node/Creating.html
Use the `msginit` command to create a new PO file for a translation. This is the recommended method for starting a new translation.
```bash
$ cd PACKAGE-VERSION
$ cd po
$ msginit
```
--------------------------------
### Example Post-processing Command
Source: https://www.gnu.org/software/gettext/manual/html_node/msgpre-Invocation.html
This example shows a post-processing command using 'sed' to remove emphasis markers like '**' from the LLM output.
```bash
sed -e 's/[*][*]//g'
```
--------------------------------
### Example LINGUAS file content
Source: https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html
This example shows how to list available languages (German and French) in the LINGUAS file. Comments and blank lines are ignored.
```plaintext
# Set of available languages.
de fr
```
--------------------------------
### Python gettext Textdomain and Bindtextdomain
Source: https://www.gnu.org/software/gettext/manual/html_node/Python.html
Illustrates how to set the text domain using `gettext.textdomain` or install it with a specific directory using `gettext.install`.
```python
gettext.textdomain
```
```python
gettext.install(domain)
```
```python
gettext.bindtextdomain
```
```python
gettext.install(domain,localedir)
```
--------------------------------
### Check gettext version and help output
Source: https://www.gnu.org/software/gettext/FAQ.html
Verify that the gettext command-line tool is installed and accessible. Output should appear in your desired language if locales are set up correctly.
```bash
$ gettext --version
```
```bash
$ gettext --help
```
--------------------------------
### Include 'po' Subdirectory Processing in Makefile.in
Source: https://www.gnu.org/software/gettext/manual/html_node/Makefile.html
Ensure the 'po' subdirectory is processed along with other subdirectories for goals like 'install', 'clean', and 'distclean'. This example shows a canonical order.
```makefile
SUBDIRS = doc lib src po
```
--------------------------------
### Use printf_gettext with a Shell Variable
Source: https://www.gnu.org/software/gettext/manual/html_node/The-printf_005fgettext-approach.html
This example demonstrates how to use printf_gettext to internationalize a message that includes a shell variable, such as a process ID. Ensure GNU gettext 0.26 or newer is installed.
```shell
printf_gettext 'Running as process number %u.' $pid; echo
```
--------------------------------
### GNU GPL Program Startup Notice (Interactive Mode)
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/GNU-GPL.html
This notice should be displayed by programs when they start in interactive mode. It provides a brief summary of the software's free nature and warranty disclaimer, directing users to 'show w' and 'show c' for more details.
```text
program Copyright (C) year name of author
This program comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’.
This is free software, and you are welcome to redistribute it
under certain conditions; type ‘show c’ for details.
```
--------------------------------
### XML Document Example
Source: https://www.gnu.org/software/gettext/manual/html_node/ITS-Rules.html
An example XML document structure containing translatable and non-translatable messages.
```xml
A translatable string
A non-translatable string
```
--------------------------------
### Informative Output Options
Source: https://www.gnu.org/software/gettext/manual/html_node/msgconv-Invocation.html
Display help information with -h or --help, and version information with -V or --version.
```bash
-h
--help
```
```bash
-V
--version
```
--------------------------------
### Read, Process, and Write PO Files with libgettextpo
Source: https://www.gnu.org/software/gettext/manual/html_node/libgettextpo.html
This example demonstrates the core workflow of using libgettextpo: reading a PO file into memory, iterating through its domains and messages, performing operations on messages, and writing the modified file back. Error handling is omitted for brevity.
```c
struct po_xerror_handler handler = {
.xerror = ...,
.xerror2 = ...
};
const char *filename = ...;
/* Read the file into memory. */
po_file_t file = po_file_read (filename, &handler);
{
const char * const *domains = po_file_domains (file);
const char * const *domainp;
/* Iterate the domains contained in the file. */
for (domainp = domains; *domainp; domainp++)
{
po_message_t *message;
const char *domain = *domainp;
po_message_iterator_t iterator = po_message_iterator (file, domain);
/* Iterate each message inside the domain. */
while ((message = po_next_message (iterator)) != NULL)
{
/* Read data from the message ... */
const char *msgid = po_message_msgid (message);
const char *msgstr = po_message_msgstr (message);
...
/* Modify its contents ... */
if (perform_some_tests (msgid, msgstr))
po_message_set_fuzzy (message, 1);
...
}
/* Always release returned po_message_iterator_t. */
po_message_iterator_free (iterator);
}
/* Write back the result. */
po_file_t result = po_file_write (file, filename, &handler);
}
/* Always release the returned po_file_t. */
po_file_free (file);
```
--------------------------------
### Python gettext Example: Named Arguments for Pluralization
Source: https://www.gnu.org/software/gettext/manual/html_node/Python.html
An example demonstrating the use of named arguments in format strings, which is beneficial for translators when dealing with plural forms.
```python
'%(volume)s' has only %(freespace)d bytes free.'
```
--------------------------------
### Display help with envsubst --help
Source: https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html
Use the --help option to display usage information and exit.
```bash
envsubst --help
```
--------------------------------
### msgcmp Informative Output Options
Source: https://www.gnu.org/software/gettext/manual/html_node/msgcmp-Invocation.html
Provides help and version information. Use '--help' to display usage instructions and '--version' to show the program's version.
```bash
msgcmp -h
```
```bash
msgcmp --help
```
```bash
msgcmp -V
```
```bash
msgcmp --version
```
--------------------------------
### Fetch PO Files (Method 2)
Source: https://www.gnu.org/software/gettext/manual/html_node/Release-Management.html
An alternative method to fetch PO files, involving configure, make, and distclean steps.
```bash
$ ./configure
$ (cd po; make fetch-po)
$ make distclean
```
--------------------------------
### Machine Translation Example with Post-processing
Source: https://www.gnu.org/software/gettext/manual/html_node/spit-Invocation.html
This example demonstrates translating a sentence into German using the `spit` program. It specifies the model and uses `sed` to clean up emphasis markers in the LLM's output.
```bash
$ echo 'Translate into German: "Welcome to the GNU project!"' \
| spit --model=ministral-3:14b \
--postprocess="sed -e 's/[*][*]//g'"
"Willkommen zum GNU-Projekt!"
```
--------------------------------
### Display Help Message
Source: https://www.gnu.org/software/gettext/manual/html_node/msginit-Invocation.html
Shows the help message for the msginit command, listing available options and their descriptions, then exits.
```bash
-h
--help
```
--------------------------------
### Declare Package and Version (Standard)
Source: https://www.gnu.org/software/gettext/manual/html_node/configure_002eac.html
Use these lines to declare the package name and version. These are then substituted into the configure script.
```autoconf
PACKAGE=gettext
VERSION=1.0
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
```
--------------------------------
### Example of Multi-line String Representation
Source: https://www.gnu.org/software/gettext/manual/html_node/Normalizing.html
Illustrates how a string with embedded newlines can be represented in a PO file. This example shows a single `msgstr` with embedded newlines versus its representation split into multiple strings.
```PO
msgstr "\n\nHello, world!\n\n\n"
```
```PO
msgstr ""
"\n"
"\n"
"Hello,\n"
"world!\n"
"\n"
"\n"
```
--------------------------------
### Input as Java Properties
Source: https://www.gnu.org/software/gettext/manual/html_node/msginit-Invocation.html
Instructs msginit to treat the input file as a Java ResourceBundle in .properties syntax instead of PO file syntax.
```bash
-P
--properties-input
```
--------------------------------
### Input as NeXTstep/GNUstep Strings
Source: https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html
Assume input files are NeXTstep/GNUstep localized resource files in `.strings` syntax.
```bash
msgfmt --stringtable-input
```
--------------------------------
### Plural-Forms Header Example (2 Plural Forms)
Source: https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
Define pluralization rules for a language using the Plural-Forms header in the PO file. This example specifies two plural forms where 'n == 1' is the singular case.
```po
Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
```
--------------------------------
### Define Distribution Directory and Goal in Makefile.in
Source: https://www.gnu.org/software/gettext/manual/html_node/src_002fMakefile.html
Sets up the directory for distribution files and defines the 'dist:' goal. This goal ensures that all specified distribution files are copied to the correct location.
```makefile
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
dist: Makefile $(DISTFILES)
for file in $(DISTFILES); do \
ln $$file $(distdir) 2>/dev/null || cp -p $$file $(distdir) || exit 1; \
done
```
--------------------------------
### html_ostream_begin_span
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Starts an HTML span element with a specified CSS class name.
```APIDOC
## Function: void html_ostream_begin_span (html_ostream_t STREAM,
const char *CLASSNAME)
### Description
Starts a ‘‘ element. The ‘CLASSNAME‘ is the name of a CSS class. It can be chosen arbitrarily and customized through the CSS file.
```
--------------------------------
### term_ostream Accessor Methods
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Provides methods to get information about a terminal output stream.
```APIDOC
## term_ostream_get_descriptor
### Description
Retrieves the file descriptor associated with the `term_ostream_t`.
### Function Signature
`int term_ostream_get_descriptor (term_ostream_t STREAM)`
## term_ostream_get_filename
### Description
Retrieves the filename associated with the `term_ostream_t`.
### Function Signature
`const char * term_ostream_get_filename (term_ostream_t STREAM)`
## term_ostream_get_tty_control
### Description
Retrieves the TTY control settings for the `term_ostream_t`.
### Function Signature
`ttyctl_t term_ostream_get_tty_control (term_ostream_t STREAM)`
## term_ostream_get_effective_tty_control
### Description
Retrieves the effective TTY control settings for the `term_ostream_t`, excluding `TTYCTL_AUTO`.
### Function Signature
`ttyctl_t term_ostream_get_effective_tty_control (term_ostream_t STREAM)`
```
--------------------------------
### term_styled_ostream Accessors
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/Accessors.html
Provides methods to get the destination stream and CSS filename of a term_styled_ostream.
```APIDOC
## term_styled_ostream_get_destination
### Description
Retrieves the destination stream of a `term_styled_ostream`.
### Function Signature
`term_ostream_t term_styled_ostream_get_destination(term_styled_ostream_t stream)`
### Parameters
- **stream** (`term_styled_ostream_t`) - The `term_styled_ostream` object.
### Returns
- `term_ostream_t` - The destination stream.
```
```APIDOC
## term_styled_ostream_get_css_filename
### Description
Retrieves the CSS filename associated with a `term_styled_ostream`.
### Function Signature
`const char * term_styled_ostream_get_css_filename(term_styled_ostream_t stream)`
### Parameters
- **stream** (`term_styled_ostream_t`) - The `term_styled_ostream` object.
### Returns
- `const char *` - The CSS filename.
```
--------------------------------
### Display Version Information
Source: https://www.gnu.org/software/gettext/manual/html_node/msgunfmt-Invocation.html
Use '-V' or '--version' to output version information and exit.
```bash
msgunfmt -V
```
```bash
msgunfmt --version
```
--------------------------------
### Standard GPL Notice for Source Files
Source: https://www.gnu.org/software/gettext/libasprintf/manual/html_node/GNU-GPL.html
Include this notice at the beginning of each source file to ensure the exclusion of warranty and specify licensing terms. It should include the program's name, copyright, and a pointer to the full license.
```text
one line to give the program's name and a brief idea of what it does.
Copyright (C) yyyy name of author
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
```
--------------------------------
### iconv_ostream Accessors
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/Accessors.html
Provides methods to get encoding information and the destination stream of an iconv_ostream.
```APIDOC
## iconv_ostream_get_from_encoding
### Description
Retrieves the source encoding of an `iconv_ostream`.
### Function Signature
`const char * iconv_ostream_get_from_encoding(iconv_ostream_t stream)`
### Parameters
- **stream** (`iconv_ostream_t`) - The `iconv_ostream` object.
### Returns
- `const char *` - The source encoding name.
```
```APIDOC
## iconv_ostream_get_to_encoding
### Description
Retrieves the destination encoding of an `iconv_ostream`.
### Function Signature
`const char * iconv_ostream_get_to_encoding(iconv_ostream_t stream)`
### Parameters
- **stream** (`iconv_ostream_t`) - The `iconv_ostream` object.
### Returns
- `const char *` - The destination encoding name.
```
```APIDOC
## iconv_ostream_get_destination
### Description
Retrieves the destination stream of an `iconv_ostream`.
### Function Signature
`ostream_t iconv_ostream_get_destination(iconv_ostream_t stream)`
### Parameters
- **stream** (`iconv_ostream_t`) - The `iconv_ostream` object.
### Returns
- `ostream_t` - The destination stream.
```
--------------------------------
### Output version information
Source: https://www.gnu.org/software/gettext/manual/html_node/msgcomm-Invocation.html
Use the --version option to display version information and exit.
```bash
-V
--version
```
--------------------------------
### noop_styled_ostream Accessor Methods
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Provides methods to get information about a no-operation styled output stream.
```APIDOC
## noop_styled_ostream_get_destination
### Description
Retrieves the destination output stream of the `noop_styled_ostream_t`.
### Function Signature
`ostream_t noop_styled_ostream_get_destination (noop_styled_ostream_t STREAM)`
## noop_styled_ostream_is_owning_destination
### Description
Checks if the `noop_styled_ostream_t` owns its destination stream.
### Function Signature
`bool noop_styled_ostream_is_owning_destination (noop_styled_ostream_t STREAM)`
```
--------------------------------
### Define Package and Version in Makefile.in
Source: https://www.gnu.org/software/gettext/manual/html_node/src_002fMakefile.html
These lines should appear near the beginning of src/Makefile.in to define the package name and version, typically using @PACKAGE@ and @VERSION@ macros.
```makefile
PACKAGE = @PACKAGE@
VERSION = @VERSION@
```
--------------------------------
### html_styled_ostream Accessor Methods
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Provides methods to get information about a styled HTML output stream.
```APIDOC
## html_styled_ostream_get_destination
### Description
Retrieves the destination output stream of the `html_styled_ostream_t`.
### Function Signature
`ostream_t html_styled_ostream_get_destination (html_styled_ostream_t STREAM)`
## html_styled_ostream_get_html_destination
### Description
Retrieves the destination HTML output stream of the `html_styled_ostream_t`.
### Function Signature
`html_ostream_t html_styled_ostream_get_html_destination (html_styled_ostream_t STREAM)`
## html_styled_ostream_get_css_filename
### Description
Retrieves the CSS filename associated with the `html_styled_ostream_t`.
### Function Signature
`const char * html_styled_ostream_get_css_filename (html_styled_ostream_t STREAM)`
```
--------------------------------
### msgexec Help and Version Options
Source: https://www.gnu.org/software/gettext/manual/html_node/msgexec-Invocation.html
Display help information or version details for the msgexec program.
```bash
msgexec -h
```
```bash
msgexec --help
```
```bash
msgexec -V
```
```bash
msgexec --version
```
--------------------------------
### term_styled_ostream Accessor Methods
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Provides methods to get information about a styled terminal output stream.
```APIDOC
## term_styled_ostream_get_destination
### Description
Retrieves the destination terminal output stream of the `term_styled_ostream_t`.
### Function Signature
`term_ostream_t term_styled_ostream_get_destination (term_styled_ostream_t STREAM)`
## term_styled_ostream_get_css_filename
### Description
Retrieves the CSS filename associated with the `term_styled_ostream_t`.
### Function Signature
`const char * term_styled_ostream_get_css_filename (term_styled_ostream_t STREAM)`
```
--------------------------------
### html_ostream Accessor Method
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Provides a method to get the destination stream of an HTML output stream.
```APIDOC
## html_ostream_get_destination
### Description
Retrieves the destination output stream of the `html_ostream_t`.
### Function Signature
`ostream_t html_ostream_get_destination (html_ostream_t STREAM)`
```
--------------------------------
### Initial C Source Preparation for gettext
Source: https://www.gnu.org/software/gettext/manual/html_node/Overview.html
Define macros to mark strings as translatable and to handle domain binding before integrating the gettext library.
```c
#define _(String) (String)
#define N_(String) String
#define textdomain(Domain)
#define bindtextdomain(Package, Directory)
```
--------------------------------
### fd_ostream Accessor Methods
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.txt
Provides methods to get information about a file descriptor output stream.
```APIDOC
## fd_ostream_get_descriptor
### Description
Retrieves the file descriptor associated with the `fd_ostream_t`.
### Function Signature
`int fd_ostream_get_descriptor (fd_ostream_t STREAM)`
## fd_ostream_get_filename
### Description
Retrieves the filename associated with the `fd_ostream_t`.
### Function Signature
`const char * fd_ostream_get_filename (fd_ostream_t STREAM)`
## fd_ostream_is_buffered
### Description
Checks if the `fd_ostream_t` is buffered.
### Function Signature
`bool fd_ostream_is_buffered (fd_ostream_t STREAM)`
```
--------------------------------
### fd_ostream Accessors
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/Accessors.html
Provides methods to get the file descriptor, filename, and buffering status of an fd_ostream.
```APIDOC
## fd_ostream_get_descriptor
### Description
Retrieves the file descriptor associated with an `fd_ostream`.
### Function Signature
`int fd_ostream_get_descriptor(fd_ostream_t stream)`
### Parameters
- **stream** (`fd_ostream_t`) - The `fd_ostream` object.
### Returns
- `int` - The file descriptor.
```
```APIDOC
## fd_ostream_get_filename
### Description
Retrieves the filename associated with an `fd_ostream`.
### Function Signature
`const char * fd_ostream_get_filename(fd_ostream_t stream)`
### Parameters
- **stream** (`fd_ostream_t`) - The `fd_ostream` object.
### Returns
- `const char *` - The filename.
```
```APIDOC
## fd_ostream_is_buffered
### Description
Checks if an `fd_ostream` is buffered.
### Function Signature
`bool fd_ostream_is_buffered(fd_ostream_t stream)`
### Parameters
- **stream** (`fd_ostream_t`) - The `fd_ostream` object.
### Returns
- `bool` - `true` if the stream is buffered, `false` otherwise.
```
--------------------------------
### ngettext Option: Help
Source: https://www.gnu.org/software/gettext/manual/html_node/ngettext-Invocation.html
Display help information for the ngettext program and exit.
```bash
ngettext -h
--help
```
--------------------------------
### Defining LOCALEDIR in Makefile
Source: https://www.gnu.org/software/gettext/manual/html_node/AM_005fGNU_005fGETTEXT.html
Example of using the localedir_c_make variable to define a C macro for LOCALEDIR in a Makefile.
```makefile
AM_CPPFLAGS = ... -DLOCALEDIR=$(localedir_c_make) ...
```
--------------------------------
### Configure 'dist' Goal in Makefile.in
Source: https://www.gnu.org/software/gettext/manual/html_node/Makefile.html
Example configuration for the 'dist' goal in Makefile.in. This goal creates a distribution directory, copies files, and archives them into a tarball. It relies on the 'po' subdirectory being correctly set up.
```makefile
distdir = $(PACKAGE)-$(VERSION)
dist: Makefile
rm -fr $(distdir)
mkdir $(distdir)
chmod 777 $(distdir)
for file in $(DISTFILES); do \
ln $$file $(distdir) 2>/dev/null || cp -p $$file $(distdir);
done
for subdir in $(SUBDIRS); do \
mkdir $(distdir)/$$subdir || exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done
tar chozf $(distdir).tar.gz $(distdir)
rm -fr $(distdir)
```
--------------------------------
### Previous msgid Functions
Source: https://www.gnu.org/software/gettext/manual/html_node/po_005fmessage_005ft-API.html
Functions to get and set the previous msgid (untranslated English string) for a message.
```APIDOC
## po_message_prev_msgid
### Description
Returns the previous `msgid` (untranslated English string) of message, or `NULL` if there is no previous `msgid` stored.
### Function Signature
`const char * po_message_prev_msgid(po_message_t message)`
## po_message_set_prev_msgid
### Description
Changes the previous `msgid` (untranslated English string) of message to the value provided through `prev_msgid`, or removes the message when it is `NULL`.
### Function Signature
`void po_message_set_prev_msgid(po_message_t message, const char *prev_msgid)`
```
--------------------------------
### Basic Styled Output Stream Operations
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/Basic-use.html
Demonstrates the lifecycle of a styled output stream, from creation to freeing. Ensure 'style_file_name' is determined and set to NULL if no styling is desired.
```c
styled_ostream_t stream =
styled_ostream_create (STDOUT_FILENO, "(stdout)", TTYCTL_AUTO,
style_file_name);
...
styled_ostream_begin_use_class (stream, css_class);
...
ostream_write_str (stream, string);
...
styled_ostream_end_use_class (stream, css_class);
...
styled_ostream_free (stream);
```
--------------------------------
### Display help message
Source: https://www.gnu.org/software/gettext/manual/html_node/msgcomm-Invocation.html
Use the --help option to display the help message and exit.
```bash
-h
--help
```
--------------------------------
### List supported locales
Source: https://www.gnu.org/software/gettext/manual/html_node/Using-This-Package.html
Run this command to get a list of locales supported by your system, filtered for your language.
```shell
locale -a | grep '^ll'
```
--------------------------------
### Assume NeXTstep/GNUstep localized resource input
Source: https://www.gnu.org/software/gettext/manual/html_node/msgcat-Invocation.html
Assumes the input files are NeXTstep/GNUstep localized resource files in `.strings` syntax, not PO file syntax.
```bash
--stringtable-input
```
--------------------------------
### noop_styled_ostream Accessors
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/Accessors.html
Provides methods to get the destination stream and check ownership of the destination stream for a noop_styled_ostream.
```APIDOC
## noop_styled_ostream_get_destination
### Description
Retrieves the destination stream of a `noop_styled_ostream`.
### Function Signature
`ostream_t noop_styled_ostream_get_destination(noop_styled_ostream_t stream)`
### Parameters
- **stream** (`noop_styled_ostream_t`) - The `noop_styled_ostream` object.
### Returns
- `ostream_t` - The destination stream.
```
```APIDOC
## noop_styled_ostream_is_owning_destination
### Description
Checks if a `noop_styled_ostream` owns its destination stream.
### Function Signature
`bool noop_styled_ostream_is_owning_destination(noop_styled_ostream_t stream)`
### Parameters
- **stream** (`noop_styled_ostream_t`) - The `noop_styled_ostream` object.
### Returns
- `bool` - `true` if the stream owns the destination, `false` otherwise.
```
--------------------------------
### Combine POT files with default domain
Source: https://www.gnu.org/software/gettext/manual/html_node/Combining-POTs.html
Use `--default-domain` to specify the output file and `--join-existing` to accumulate strings from multiple sources.
```bash
xgettext --default-domain=all a.c
xgettext --default-domain=all --join-existing b.py
mv all.po all.pot
```
--------------------------------
### term_ostream Accessors
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/Accessors.html
Provides methods to get the file descriptor, filename, and TTY control information of a term_ostream.
```APIDOC
## term_ostream_get_descriptor
### Description
Retrieves the file descriptor associated with a `term_ostream`.
### Function Signature
`int term_ostream_get_descriptor(term_ostream_t stream)`
### Parameters
- **stream** (`term_ostream_t`) - The `term_ostream` object.
### Returns
- `int` - The file descriptor.
```
```APIDOC
## term_ostream_get_filename
### Description
Retrieves the filename associated with a `term_ostream`.
### Function Signature
`const char * term_ostream_get_filename(term_ostream_t stream)`
### Parameters
- **stream** (`term_ostream_t`) - The `term_ostream` object.
### Returns
- `const char *` - The filename.
```
```APIDOC
## term_ostream_get_tty_control
### Description
Retrieves the TTY control information of a `term_ostream`.
### Function Signature
`ttyctl_t term_ostream_get_tty_control(term_ostream_t stream)`
### Parameters
- **stream** (`term_ostream_t`) - The `term_ostream` object.
### Returns
- `ttyctl_t` - The TTY control information.
```
```APIDOC
## term_ostream_get_effective_tty_control
### Description
Retrieves the effective TTY control of the stream, which is not `TTYCTL_AUTO`.
### Function Signature
`ttyctl_t term_ostream_get_effective_tty_control(term_ostream_t stream)`
### Parameters
- **stream** (`term_ostream_t`) - The `term_ostream` object.
### Returns
- `ttyctl_t` - The effective TTY control information.
```
--------------------------------
### fprintf with custom directive
Source: https://www.gnu.org/software/gettext/manual/html_node/No-custom-format-directives.html
This example shows the incorrect usage of a custom format directive within a translatable string.
```c
fprintf (stream, _("The contents is: %r"), data);
```
--------------------------------
### styled_ostream_end_use_class
Source: https://www.gnu.org/software/gettext/libtextstyle/manual/html_node/The-styled_005fostream-class.html
Ends a run of text that was previously started with styled_ostream_begin_use_class. Calls to begin and end must be properly matched.
```APIDOC
## styled_ostream_end_use_class
### Description
Ends a run of text belonging to `classname`. The `styled_ostream_begin_use_class` / `styled_ostream_end_use_class` calls must match properly.
### Function Signature
void styled_ostream_end_use_class(styled_ostream_t stream, const char *classname)
```
--------------------------------
### Gettextize command example
Source: https://www.gnu.org/software/gettext/FAQ.html
The gettextize command is used to set up gettext support in a project. It typically copies necessary files into po/, intl/, and m4/ directories and updates Makefile.am and configure.ac.
```bash
gettextize
```