patch 9.1.1064: not possible to use plural forms with gettext()
Problem: not possible to use plural forms with gettext()
Solution: implement ngettext() Vim script function (Christ van Willegen)
closes: #16561
Signed-off-by: Christ van Willegen <cvwillegen@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 6f5219c..e222d7c 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -416,6 +416,8 @@
mode([{expr}]) String current editing mode
mzeval({expr}) any evaluate |MzScheme| expression
nextnonblank({lnum}) Number line nr of non-blank line >= {lnum}
+ngettext({single}, {plural}, {number}[, {domain}])
+ String translate text based on {number}
nr2char({expr} [, {utf8}]) String single char with ASCII/UTF-8 value {expr}
or({expr}, {expr}) Number bitwise OR
pathshorten({expr} [, {len}]) String shorten directory names in a path
@@ -7687,6 +7689,20 @@
Return type: |Number|
+ngettext({single}, {plural}, {number}[, {domain}) *ngettext()*
+ Return a string that contains the correct value for a
+ message based on the rules for plural form(s) in
+ a language. Examples: >
+ ngettext("File", "Files", 2) # returns "Files"
+<
+ Can be used as a |method|: >
+ 1->ngettext("File", "Files") # returns "File"
+<
+ See |gettext()| for information on the domain parameter.
+
+ Return type: |String|
+
+
nr2char({expr} [, {utf8}]) *nr2char()*
Return a string with a single character, which has the number
value {expr}. Examples: >
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 378fb83..7acca38 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -9260,6 +9260,7 @@
new-virtedit version6.txt /*new-virtedit*
news intro.txt /*news*
nextnonblank() builtin.txt /*nextnonblank()*
+ngettext() builtin.txt /*ngettext()*
no-eval-feature eval.txt /*no-eval-feature*
no-type-checking eval.txt /*no-type-checking*
no_buffers_menu gui.txt /*no_buffers_menu*
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 35aba02..0d09fc9 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1,4 +1,4 @@
-*usr_41.txt* For Vim version 9.1. Last change: 2025 Jan 16
+*usr_41.txt* For Vim version 9.1. Last change: 2025 Feb 01
VIM USER MANUAL - by Bram Moolenaar
@@ -801,6 +801,7 @@
trim() trim characters from a string
bindtextdomain() set message lookup translation base path
gettext() lookup message translation
+ ngettext() lookup single/plural message translation
str2blob() convert a list of strings into a blob
blob2str() convert a blob into a list of strings
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 2e16e09..64f49a6 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41660,6 +41660,7 @@
Channel or Blob variable
|matchbufline()| all the matches of a pattern in a buffer
|matchstrlist()| all the matches of a pattern in a List of strings
+|ngettext()| lookup single/plural message translation
|popup_setbuf()| switch to a different buffer in a popup
|str2blob()| convert a List of strings into a blob