gettext/gettext-tools/doc/lang-javascript.texi
Bruno Haible 967e76ba4f xgettext: JavaScript: Support customized handling of tagged template literals.
Reported by Evan Welsh <contact@evanwelsh.com>
and Philip Chimento <philip.chimento@gmail.com>
at <https://savannah.gnu.org/bugs/index.php?60027>.

* gettext-tools/src/str-list.h (string_list_append_move): New declaration.
* gettext-tools/src/str-list.c (string_list_append_move): New function.
* gettext-tools/src/x-javascript.h (x_javascript_tag): New declaration.
* gettext-tools/src/x-javascript.c: Include str-list.h.
(tag_step1_fn): New type.
(gnome_step1, get_tag_step1_fn): New functions.
(struct tag_definition): New type.
(tags): New variable.
(x_javascript_tag): New function.
(struct token_ty): Add fields template_tag, template_parts.
(free_token): Update.
(struct level_info): New type.
(levels): Change element type to 'struct level_info'.
(new_level, level_type): Update.
(phase5_get, x_javascript_lex): Arrange to collect the parts of a template
literal in the last token's template_parts field.
(extract_balanced): Handle tagged template literals.
* gettext-tools/src/xgettext.c (long_options): Add option --tag.
(main): Handle option --tag.
(usage): Document ption --tag.
* gettext-tools/tests/xgettext-javascript-13: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* gettext-tools/doc/gettext.texi (No string concatenation): Mention the tagged
template literals as alternative.
* gettext-tools/doc/xgettext.texi: Document the --tag option.
* gettext-tools/doc/lang-javascript.texi (JavaScript): Mention the tagged
template literals syntax.
* NEWS: Mention the change.
2024-09-28 02:09:36 +02:00

74 lines
1.4 KiB
Plaintext

@c This file is part of the GNU gettext manual.
@c Copyright (C) 1995-2024 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.
@node JavaScript
@subsection JavaScript
@table @asis
@item RPMs
js
@item Ubuntu packages
gjs
@item File extension
@code{js}
@item String syntax
@itemize @bullet
@item @code{"abc"}
@item @code{'abc'}
@item @code{`abc`}
@c https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
@item @code{@var{tag}`abc$@{@var{expression}@}def@{@var{expression}@}...`},
see the description of @samp{--tag} in @ref{xgettext Invocation}.
@end itemize
@item gettext shorthand
@code{_("abc")}
@item gettext/ngettext functions
@code{gettext}, @code{dgettext}, @code{dcgettext}, @code{ngettext},
@code{dngettext}
@item textdomain
@code{textdomain} function
@item bindtextdomain
@code{bindtextdomain} function
@item setlocale
automatic
@item Prerequisite
---
@item Use or emulate GNU gettext
use, or emulate
@item Extractor
@code{xgettext}
@item Formatting with positions
A @code{format} method on strings can be used.
But since it is not standard in JavaScript,
you have to enable it yourself, through
@example
const Format = imports.format;
String.prototype.format = Format.format;
@end example
@item Portability
On platforms without gettext, the functions are not available.
@item po-mode marking
---
@end table