diff --git a/Filelist b/Filelist index ab4b1ebaae..1652cf37e2 100644 --- a/Filelist +++ b/Filelist @@ -221,6 +221,7 @@ SRC_ALL = \ src/testdir/silent.wav \ src/testdir/popupbounce.vim \ src/testdir/crash/* \ + src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mo \ src/proto.h \ src/protodef.h \ src/proto/alloc.pro \ diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index c1dd26020a..34c0b0a673 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 @@ autocmd_get([{opts}]) List return a list of autocmds 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 @@ gettabvar({nr}, {varname} [, {def}]) 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 @@ balloon_split({msg}) *balloon_split()* Return type: list or list +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 @@ gettagstack([{winnr}]) *gettagstack()* Return type: dict -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 @@ gettext({text}) *gettext()* 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| 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//LC_MESSAGES/foo.po + " messages for the plugin in the + " 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//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//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("