patch 9.1.0509: not possible to translate Vim script messages
Problem: not possible to translate Vim script messages
(RestorerZ)
Solution: implement bindtextdomain() and gettext() to support Vim script
message translations (Christ van Willegen)
fixes: #11637
closes: #12447
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 c1dd260..34c0b0a 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1,4 +1,4 @@
-*builtin.txt* For Vim version 9.1. Last change: 2024 Jun 19
+*builtin.txt* For Vim version 9.1. Last change: 2024 Jun 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -67,6 +67,8 @@
balloon_gettext() String current text in the balloon
balloon_show({expr}) none show {expr} inside the balloon
balloon_split({msg}) List split {msg} as used for a balloon
+bindtextdomain({package}, {path})
+ none bind text domain to specied path
blob2list({blob}) List convert {blob} into a list of numbers
browse({save}, {title}, {initdir}, {default})
String put up a file requester
@@ -277,7 +279,8 @@
gettabwinvar({tabnr}, {winnr}, {name} [, {def}])
any {name} in {winnr} in tab page {tabnr}
gettagstack([{nr}]) Dict get the tag stack of window {nr}
-gettext({text}) String lookup translation of {text}
+gettext({text} [, {package}])
+ String lookup translation of {text}
getwininfo([{winid}]) List list of info about each window
getwinpos([{timeout}]) List X and Y coord in pixels of Vim window
getwinposx() Number X coord in pixels of the Vim window
@@ -1218,6 +1221,13 @@
Return type: list<any> or list<string>
+bindtextdomain({package}, {path}) *bindtextdomain()*
+ Bind a specific {package} to a {path} so that the
+ |gettext()| function can be used to get language-specific
+ translations for a package. {path} is the directory name
+ for the translations. See |package-create|.
+
+ Return type: none
blob2list({blob}) *blob2list()*
Return a List containing the number value of each byte in Blob
@@ -4978,7 +4988,7 @@
Return type: dict<any>
-gettext({text}) *gettext()*
+gettext({text} [, {package}]) *gettext()*
Translate String {text} if possible.
This is mainly for use in the distributed Vim scripts. When
generating message translations the {text} is extracted by
@@ -4988,6 +4998,9 @@
For {text} double quoted strings are preferred, because
xgettext does not understand escaping in single quoted
strings.
+ When the {package} is specified, the translation is looked up
+ for that specific package. You need to specify the path to
+ look for translations with the |bindtextdomain()| function.
Return type: |String|