summaryrefslogtreecommitdiffstats
path: root/runtime/doc/repeat.txt
diff options
context:
space:
mode:
authorChrist van Willegen <cvwillegen@gmail.com>2024-06-20 23:41:59 +0200
committerChristian Brabandt <cb@256bit.org>2024-06-20 23:41:59 +0200
commitce0ef910df837b9b961f007a0a35064cad85188b (patch)
treebd8b18ad704b6166904c78b706b1a4e359e3124b /runtime/doc/repeat.txt
parentf7f8f0b76dc6a3bf5d51825db65245221e5d265e (diff)
patch 9.1.0509: not possible to translate Vim script messagesv9.1.0509
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>
Diffstat (limited to 'runtime/doc/repeat.txt')
-rw-r--r--runtime/doc/repeat.txt35
1 files changed, 34 insertions, 1 deletions
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index e95b6a1ae6..0bfb1177c2 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -1,4 +1,4 @@
-*repeat.txt* For Vim version 9.1. Last change: 2023 May 26
+*repeat.txt* For Vim version 9.1. Last change: 2024 Jun 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -735,6 +735,10 @@ Your directory layout would be like this:
start/foobar/autoload/foo.vim " loaded when foo command used
start/foobar/doc/foo.txt " help for foo.vim
start/foobar/doc/tags " help tags
+ start/foobar/lang/<lang_id>/LC_MESSAGES/foo.po
+ " messages for the plugin in the
+ " <lang_id> language. These files are
+ " optional.
opt/fooextra/plugin/extra.vim " optional plugin, defines commands
opt/fooextra/autoload/extra.vim " loaded when extra command used
opt/fooextra/doc/extra.txt " help for extra.vim
@@ -762,6 +766,35 @@ the command after changing the plugin help: >
:helptags path/start/foobar/doc
:helptags path/opt/fooextra/doc
+The messages that are in the lang/<lang_id>/LC_MESSAGES/foo.po file need to be
+translated to a format that the |gettext()| function understands by running the
+msgfmt program. This will result in a lang/<lang_id>/LC_MESSAGES/foo.mo
+file. See |multilang| on how to specify languages.
+
+In your plugin, you need to call the |bindtextdomain()| function as follows.
+This assumes that the directory structure is as above: >
+ :call bindtextdomain("foo", fnamemodify(expand("<script>"), ':p:h')
+ .. '/../lang/')
+<
+You only need to do this once. After this call, you can use: >
+ :echo gettext("Hello", "foo")
+<
+to get the text "Hello" translated to the user's preferred language (if the
+plugin messages have been translated to this language).
+
+To create the foo.po file, you need to create a foo.pot file first. The
+entries in this file need to be translated to the language(s) you want to be
+supported by your plugin.
+
+To create the foo.pot file, run the following command: >
+ cd ~/.vim/pack/start/foobar
+ make -f ~/src/vim/src/po/Makefile PACKAGE=foo \
+ PO_BASEDIR=~/src/vim/src/po PO_INPUTLIST= \
+ PO_VIM_JSLIST="plugin__foo.js plugin__bar.js \
+ autoload__foo.js" \
+ PO_VIM_INPUTLIST="plugin/foo.vim plugin/bar.vim autoload/foo.vim" \
+ foo.pot
+<
Dependencies between plugins ~
*packload-two-steps*