From: Bruno Haible Date: Sun, 8 Sep 2024 08:02:23 +0000 (+0200) Subject: doc: Enhance doc about format strings in JavaScript. X-Git-Tag: v0.23~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e8ad0213284e3ed867e65d9c6652ff569fdadde;p=thirdparty%2Fgettext.git doc: Enhance doc about format strings in JavaScript. * gettext-tools/doc/lang-javascript.texi (JavaScript): Document how to get a decent 'format' method. --- diff --git a/gettext-tools/doc/lang-javascript.texi b/gettext-tools/doc/lang-javascript.texi index 21b1ea794..c678725ec 100644 --- a/gettext-tools/doc/lang-javascript.texi +++ b/gettext-tools/doc/lang-javascript.texi @@ -1,5 +1,5 @@ @c This file is part of the GNU gettext manual. -@c Copyright (C) 1995-2020 Free Software Foundation, Inc. +@c Copyright (C) 1995-2024 Free Software Foundation, Inc. @c See the file gettext.texi for copying conditions. @node JavaScript @@ -52,7 +52,14 @@ use, or emulate @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.