diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-30 15:52:10 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-30 15:52:10 +0200 |
commit | 0b39c3fd4c5d1c8ebd2efa85fced7df5e17efd3b (patch) | |
tree | 6d230d3ef3310ad4aa28801d3720d33c29a19a4b /runtime | |
parent | 25859dd74cd5befe964627dc03b8369dfaebe837 (diff) |
patch 8.2.1544: cannot translate messages in a Vim scriptv8.2.1544
Problem: Cannot translate messages in a Vim script.
Solution: Add gettext(). Try it out for a few messages in the options
window.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/eval.txt | 14 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 | ||||
-rw-r--r-- | runtime/optwin.vim | 16 |
3 files changed, 23 insertions, 8 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index e0c8473038..f1b6992196 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2546,6 +2546,7 @@ 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} getwininfo([{winid}]) List list of info about each window getwinpos([{timeout}]) List X and Y coord in pixels of the Vim window getwinposx() Number X coord in pixels of the Vim window @@ -5827,6 +5828,19 @@ gettagstack([{nr}]) *gettagstack()* Can also be used as a |method|: > GetWinnr()->gettagstack() + +gettext({text}) *gettext()* + Translate {text} if possible. + This is mainly for use in the distributed Vim scripts. When + generating message translations the {text} is extracted by + xgettext, the translator can add the translated message in the + .po file and Vim will lookup the translation when gettext() is + called. + For {text} double quoted strings are preferred, because + xgettext does not understand escaping in single quoted + strings. + + getwininfo([{winid}]) *getwininfo()* Returns information about windows as a |List| with Dictionaries. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 10e53baf72..81474c7f42 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -628,6 +628,7 @@ String manipulation: *string-functions* execute() execute an Ex command and get the output win_execute() like execute() but in a specified window trim() trim characters from a string + gettext() lookup message translation List manipulation: *list-functions* get() get an item without error for wrong index diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 5bb78cdb0a..67601a8422 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2020 Jun 10 +" Last Change: 2020 aug 30 " If there already is an option window, jump to that one. let buf = bufnr('option-window') @@ -145,13 +145,13 @@ exe $OPTWIN_CMD . ' new option-window' setlocal ts=15 tw=0 noro buftype=nofile " Insert help and a "set" command for each option. -call append(0, '" Each "set" line shows the current value of an option (on the left).') -call append(1, '" Hit <CR> on a "set" line to execute it.') -call append(2, '" A boolean option will be toggled.') -call append(3, '" For other options you can edit the value before hitting <CR>.') -call append(4, '" Hit <CR> on a help line to open a help window on this option.') -call append(5, '" Hit <CR> on an index line to jump there.') -call append(6, '" Hit <Space> on a "set" line to refresh it.') +call append(0, gettext('" Each "set" line shows the current value of an option (on the left).')) +call append(1, gettext('" Hit <Enter> on a "set" line to execute it.')) +call append(2, gettext('" A boolean option will be toggled.')) +call append(3, gettext('" For other options you can edit the value before hitting <Enter>.')) +call append(4, gettext('" Hit <Enter> on a help line to open a help window on this option.')) +call append(5, gettext('" Hit <Enter> on an index line to jump there.')) +call append(6, gettext('" Hit <Space> on a "set" line to refresh it.')) " These functions are called often below. Keep them fast! |