[vim/vim] Add gettext() package and encoding argument (PR #12447)

99 views
Skip to first unread message

cvwillegen

unread,
May 26, 2023, 6:32:05 AM5/26/23
to vim/vim, Subscribed

This PR adds the possibility to translate strings in packages using gettext("message", "package", "encoding").

Implements #11637


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/12447

Commit Summary

  • 6367a91 Implement bindtextdomain() and gettext(..., package, encoding)
  • ec534b7 Merge branch 'vim:master' into add-gettext-package-argument
  • 1d9b244 Add new test files.

File Changes

(8 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447@github.com>

zeertzjq

unread,
May 26, 2023, 6:43:38 AM5/26/23
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In runtime/doc/builtin.txt:

> @@ -266,7 +268,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}[, {encoding}]])
⬇️ Suggested change
-gettext({text}[, {package}[, {encoding}]])
+gettext({text} [, {package} [, {encoding}]])

In runtime/doc/builtin.txt:

> @@ -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}])
⬇️ Suggested change
-bindtextdomain({package}[, {path}])
+bindtextdomain({package} [, {path}])

In runtime/doc/builtin.txt:

> @@ -1156,6 +1159,13 @@ balloon_split({msg})					*balloon_split()*
 <		{only available when compiled with the |+balloon_eval_term|
 		feature}
 
+bindtextdomain({package}[, {path}])			*bindtextdomain()*
⬇️ Suggested change
-bindtextdomain({package}[, {path}])			*bindtextdomain()*
+bindtextdomain({package} [, {path}])			*bindtextdomain()*

In runtime/doc/builtin.txt:

> @@ -4276,7 +4286,7 @@ gettagstack([{winnr}])					*gettagstack()*
 			GetWinnr()->gettagstack()
 
 
-gettext({text})						*gettext()*
+gettext({text}[, {package}[, {encoding}]])		*gettext()*
⬇️ Suggested change
-gettext({text}[, {package}[, {encoding}]])		*gettext()*
+gettext({text} [, {package} [, {encoding}]])		*gettext()*


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/review/1445942080@github.com>

cvwillegen

unread,
May 26, 2023, 7:10:50 AM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 3099ff1 Apply suggestions from code review


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13771537064@github.com>

cvwillegen

unread,
May 26, 2023, 7:15:52 AM5/26/23
to vim/vim, Subscribed

bindtextdomain() and bind_textdomain_codeset() change the setting of the current process. So, they affect the translation of Vim itself.

Maybe we should change them temporarily only when calling gettext() from Vim script?

bindtextdomain should only be used with a specifier indicating the package (so not "vim". Perhaps we should check this...). The codeset is only changed during one call of the _() function, so that doesn't influence the translation of Vim itself.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1564234860@github.com>

cvwillegen

unread,
May 26, 2023, 7:22:24 AM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 383dbd4 Make sure that the "vim" package translations cannot be changed.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13771660477@github.com>

cvwillegen

unread,
May 26, 2023, 7:28:24 AM5/26/23
to vim/vim, Push

@cvwillegen pushed 2 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13771721953@github.com>

cvwillegen

unread,
May 26, 2023, 7:50:21 AM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 56987ee Add new global function to function list

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13771947595@github.com>

cvwillegen

unread,
May 26, 2023, 7:51:30 AM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 0952b62 Cherry-pick fix for FreeBSD tests failing

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13771959286@github.com>

cvwillegen

unread,
May 26, 2023, 10:29:10 AM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • fbd96b6 bind_textdomain_codeset needs to be a feature.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13773887987@github.com>

cvwillegen

unread,
May 26, 2023, 12:36:24 PM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 0ed353c Merge branch 'vim:master' into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13775246782@github.com>

cvwillegen

unread,
May 26, 2023, 12:38:33 PM5/26/23
to vim/vim, Push

@cvwillegen pushed 2 commits.

  • 5c01394 Fix argument checking.
  • f3a42eb Merge branch 'add-gettext-package-argument' of github.com:cvwillegen/vim into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13775266050@github.com>

cvwillegen

unread,
May 26, 2023, 1:40:23 PM5/26/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • c23e79b Fix spelling, fix warning for unused arguments.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13775830902@github.com>

codecov[bot]

unread,
May 26, 2023, 2:21:11 PM5/26/23
to vim/vim, Subscribed

Codecov Report

Merging #12447 (c23e79b) into master (9f3afe7) will increase coverage by 0.64%.
The diff coverage is 13.79%.

@@            Coverage Diff             @@
##           master   #12447      +/-   ##
==========================================
+ Coverage   82.07%   82.71%   +0.64%     
==========================================
  Files         160      150      -10     
  Lines      193564   180404   -13160     
  Branches    43468    40553    -2915     
==========================================
- Hits       158860   149228    -9632     
+ Misses      21851    18211    -3640     
- Partials    12853    12965     +112     
Flag Coverage Δ
huge-clang-none 82.71% <13.79%> (-0.01%) ⬇️
linux 82.71% <13.79%> (-0.01%) ⬇️
mingw-x64-HUGE ?
mingw-x86-HUGE ?
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/version.c 84.74% <ø> (-0.51%) ⬇️
src/evalfunc.c 88.32% <13.79%> (-1.85%) ⬇️

... and 141 files with indirect coverage changes


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1564759830@github.com>

Bram Moolenaar

unread,
May 26, 2023, 2:41:05 PM5/26/23
to vim/vim, Subscribed


> This PR adds the possibility to translate strings in packages using
> gettext("message", "package", "encoding").
>
> Implements #11637

Thanks for working on this. For a new feature like this it is important
to "get it right". Once plugin authors start using it we can't change
how it works without causing trouble.

It would be good to add a section to the help explaining, step-by-step,
how to add translations to a plugin. ":help package-create" is a good
place for this. This should make clear how bindtextdomain() needs to be
used and what package name to use there. When this is written down we
may spot something that is complicated. Making the
"src/po/tojavascript.vim" script available comes to mind.

Do we really need the {encoding} argument for gettext()? Since strings
inside Vim script are always using 'encoding' I don't see how getting a
string in another encoding can be useful.

Instead of using textdomain() calls before and after using gettext(),
can we use dgettext()? I'm not sure how widespread dgettext() is. If
we need to use #ifdefs in case it is not available, that isn't more
elegant than using textdomain() twice. However, I wonder what this
means for efficiency. Does gettext() cache some information that is
lost when using another domain name?

For the f_gettext() implementation, if the second argument is NULL or an
empty string, it should behave like the argument is not present. That
resembles what dgettext() does.

--
hundred-and-one symptoms of being an internet addict:
84. Books in your bookcase bear the names Bongo, WinSock and Inside OLE

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1564784119@github.com>

Restorer

unread,
May 26, 2023, 3:47:09 PM5/26/23
to vim/vim, Subscribed

@cvwillegen Thank you very much! «Сбылась мечта идиота!» :-)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1564851959@github.com>

Restorer

unread,
May 26, 2023, 4:05:04 PM5/26/23
to vim/vim, Subscribed

Do we really need the {encoding} argument for gettext()? Since strings inside Vim script are always using 'encoding' I don't see how getting a string in another encoding can be useful.

Yes, Bram, I think it's necessary.
For example, this issue #11625 comes to mind. The problem there was never completely solved.
And with this argument, it would be possible, for example, to do something like this:

let enc = &enc
if "cp1251" == enc
   g:menutrans_set_lang_to = gettext("Включить для языка", "menu", "cp1251")
elseif "utf-8" == enc
   g:menutrans_set_lang_to = gettext("Включить для языка", "menu", "utf8")
endif

It remains only to understand whether this will work dynamically? As you correctly noted.

In general, the implementation of this function in such an expanded form would allow, for example, to take out of the package vim.mo everything related to optwin.vim and defaults.vim in separate packages for them. This would improve, in my opinion, the purity of the code ‐ each module has a separate package. Which, in turn, would allow, for example, to have translated messages and an interface, but the settings window is in English.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1564879133@github.com>

Bram Moolenaar

unread,
May 26, 2023, 6:35:13 PM5/26/23
to vim/vim, Subscribed


> > Do we really need the {encoding} argument for gettext()? Since
> > strings inside Vim script are always using 'encoding' I don't see
> > how getting a string in another encoding can be useful.
>
> Yes, Bram, I think it's necessary.
> For example, this issue #11625 comes to mind. The problem there was
> never completely solved.
> And with this argument, it would be possible, for example, to do
> something like this:
> ```
> let enc = &enc
> if "cp1251" == enc
> g:menutrans_set_lang_to = gettext("Включить для языка", "menu", "cp1251")
> elseif "utf-8" == enc
> g:menutrans_set_lang_to = gettext("Включить для языка", "menu", "utf8")
> endif
>
> ```

Using the value of 'encoding' for the encoding of the resulting text
would be the default. Thus it would already do what you illustrated
without passing an extra argument with the encoding name. The question
is if it would ever be useful to use another encoding than what is the
value of the 'encoding' option.


> It remains only to understand whether this will work dynamically? As
> you correctly noted.
>
> In general, the implementation of this function in such an expanded
> form would allow, for example, to take out of the package vim.mo
> everything related to optwin.vim and defaults.vim in separate packages
> for them. This would improve, in my opinion, the purity of the code ‐
> each module has a separate package. Which, in turn, would allow, for
> example, to have translated messages and an interface, but the
> settings window is in English.

Having multiple packages makes the installation more complex. I do not
see a real advantage in having multiple packages. I have not heard
anyone ask for not using translations for the settings window only.
This looks like a theoretical thing, not a practical improvement that
users will want to use.


--
hundred-and-one symptoms of being an internet addict:
85. Choice between paying Compuserve bill and paying for kids education
is a no brainer -- although a bit painful for your kids.


/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1565031658@github.com>

cvwillegen

unread,
Jun 2, 2023, 12:22:21 PM6/2/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 23585ac Merge branch 'vim:master' into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13851783801@github.com>

cvwillegen

unread,
Jun 2, 2023, 12:22:21 PM6/2/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 23585ac Merge branch 'vim:master' into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/13851783790@github.com>

cvwillegen

unread,
Jul 10, 2023, 7:14:06 AM7/10/23
to vim/vim, Push

@cvwillegen pushed 4 commits.

  • 78bb2b8 Cleanup #define, add check for dgettext()
  • dd70fbf Fix program flow for NULL arguments, use dgettext() if available. Don't use literal "vim".
  • d1c06b3 Merge branch 'add-gettext-package-argument' of github.com:cvwillegen/vim into add-gettext-package-argument
  • a6d6f99 Update documentation, fix generating pot file from plugin directory.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/14263910471@github.com>

cvwillegen

unread,
Aug 11, 2023, 11:35:25 AM8/11/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 83e49a0 Merge branch 'vim:master' into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/14645995641@github.com>

cvwillegen

unread,
Aug 11, 2023, 5:51:39 PM8/11/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • c46dcda Merge branch 'vim:master' into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/14649344592@github.com>

cvwillegen

unread,
Aug 12, 2023, 5:59:18 AM8/12/23
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 4d5f658 Merge branch 'vim:master' into add-gettext-package-argument

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/14652361703@github.com>

cvwillegen

unread,
Feb 29, 2024, 9:04:56 AMFeb 29
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 692dec8 Merge branch 'master' into add-gettext-package-argument


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/17327264552@github.com>

cvwillegen

unread,
Feb 29, 2024, 9:39:17 AMFeb 29
to vim/vim, Push

@cvwillegen pushed 1 commit.

  • 91f7e01 Add missing file to Filelist.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/17327884871@github.com>

cvwillegen

unread,
Feb 29, 2024, 9:47:46 AMFeb 29
to vim/vim, Push

@cvwillegen pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/17328030127@github.com>

Christian Brabandt

unread,
Mar 9, 2024, 12:07:01 PMMar 9
to vim/vim, Subscribed

is this ready?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1986918930@github.com>

Christ van Willegen

unread,
Mar 10, 2024, 9:58:01 AMMar 10
to vim...@googlegroups.com, reply+ACY5DGHFMMVODW5FA6...@reply.github.com
Hi,

On Sat, Mar 9, 2024 at 6:07 PM Christian Brabandt <vim-dev...@256bit.org> wrote:

is this ready?


Yes, but I'm totally unhappy with the way you need to invoke the Makefile to get this to work, but I couldn't think of a better way :-(

Christ van Willegen
 

vim-dev ML

unread,
Mar 10, 2024, 9:58:28 AMMar 10
to vim/vim, vim-dev ML, Your activity

Hi,

On Sat, Mar 9, 2024 at 6:07 PM Christian Brabandt ***@***.***>
wrote:

> is this ready?
>

Yes, but I'm totally unhappy with the way you need to invoke the Makefile
to get this to work, but I couldn't think of a better way :-(

Christ van Willegen


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/c1987242200@github.com>

cvwillegen

unread,
Mar 21, 2024, 8:03:04 AMMar 21
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.

  • 4ae498b Merge branch 'master' into add-gettext-package-argument


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/17644228199@github.com>

cvwillegen

unread,
Mar 21, 2024, 8:10:07 AMMar 21
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.

  • 0975ab9 Take fixes in comments from upstream into account.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/17644335063@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:24:53 PMMar 21
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In Filelist:

> @@ -219,6 +219,7 @@ SRC_ALL =	\
 		src/testdir/silent.wav \
 		src/testdir/popupbounce.vim \
 		src/testdir/crash/* \
+		src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mo \

I think we also need the PACKAGE.po file


Reply to this email directly, view it on GitHub.
You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1953341958@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:27:42 PMMar 21
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In runtime/doc/repeat.txt:

> @@ -762,6 +765,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

do we need to specify in what <lang_id> should look like?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1953348091@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:29:23 PMMar 21
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In runtime/doc/repeat.txt:

> +
+In your plugin, you need to call the |bindtextdomain()| function as follows.
+This assumes that the directory structure is as above: >
+	:call bindtextdomain("foo", getcwd()~"../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).
+
+If you need to use the message in a different encoding from the current one,
+you can use (for instance) >
+	:echo gettext("Hello", "foo", "utf-8")
+<or >
+	:echo gettext("Hello", "foo", "cp1251")

so the returned encoding is in cp1251?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1953351738@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:30:03 PMMar 21
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In runtime/doc/repeat.txt:

> +plugin messages have been translated to this language).
+
+If you need to use the message in a different encoding from the current one,
+you can use (for instance) >
+	:echo gettext("Hello", "foo", "utf-8")
+<or >
+	:echo gettext("Hello", "foo", "cp1251")
+
+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
+<

that sounds difficult for a user, that just wants to translate some messages.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1953352734@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:32:57 PMMar 21
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/po/Make_all.mak:

> @@ -189,8 +189,8 @@ PO_VIM_INPUTLIST = \
 	../../runtime/defaults.vim
 
 PO_VIM_JSLIST = \
-	optwin.js \
-	defaults.js
+	________runtime__optwin.js \
+	________runtime__defaults.js

why are those files renamed?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1953357874@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:36:49 PMMar 21
to vim/vim, vim-dev ML, Comment

Just wondering, do we really need the encoding option? Wouldn't it make more sense to always use whatever Vims default encoding is? Or otherways around it, is Vim really capable to handle vimscript strings in a different encoding other than the default?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2013682605@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:04:45 AMMar 22
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In Filelist:

> @@ -219,6 +219,7 @@ SRC_ALL =	\
 		src/testdir/silent.wav \
 		src/testdir/popupbounce.vim \
 		src/testdir/crash/* \
+		src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mo \

Maybe, but I don't know where it's gone :-/


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1954889691@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:09:08 AMMar 22
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In runtime/doc/repeat.txt:

> @@ -762,6 +765,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

In "mlang.txt" there is this nugget:

where "xx" is the abbreviation of the language (mostly two letters).

Perhaps I can link to multilang-messages here??


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1954901904@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:09:24 AMMar 22
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In runtime/doc/repeat.txt:

> +
+In your plugin, you need to call the |bindtextdomain()| function as follows.
+This assumes that the directory structure is as above: >
+	:call bindtextdomain("foo", getcwd()~"../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).
+
+If you need to use the message in a different encoding from the current one,
+you can use (for instance) >
+	:echo gettext("Hello", "foo", "utf-8")
+<or >
+	:echo gettext("Hello", "foo", "cp1251")

Yes, it is.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1954902547@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:13:16 AMMar 22
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/po/Make_all.mak:

> @@ -189,8 +189,8 @@ PO_VIM_INPUTLIST = \
 	../../runtime/defaults.vim
 
 PO_VIM_JSLIST = \
-	optwin.js \
-	defaults.js
+	________runtime__optwin.js \
+	________runtime__defaults.js

I needed the directories that those files reside in, so that both a plugin/foo.js and an autoload/foo.js can be read for messages to translate. Besides, these are temporary files...


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1954913674@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:13:52 AMMar 22
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In runtime/doc/repeat.txt:

> +plugin messages have been translated to this language).
+
+If you need to use the message in a different encoding from the current one,
+you can use (for instance) >
+	:echo gettext("Hello", "foo", "utf-8")
+<or >
+	:echo gettext("Hello", "foo", "cp1251")
+
+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
+<

It's not the translation per se, it's the plugin writer that wants to have their messages translated to another language... and for that, the Vim script needs to be 'converted' to "Javascript" in order to be read by the xgettext program. And I wasn't really happy with the way to run the Makefile, but I couldn't think of another way to get the plumbing to work...


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/1954915003@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:15:34 AMMar 22
to vim/vim, vim-dev ML, Comment

Just wondering, do we really need the encoding option? Wouldn't it make more sense to always use whatever Vims default encoding is? Or otherways around it, is Vim really capable to handle vimscript strings in a different encoding other than the default?

I'm not sure, @RestorerZ explicitly asked for the encoding option. Bram also wasn't sure about it, but the encoding part is not the ugly bit of the code :-)


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2015199821@github.com>

cvwillegen

unread,
Mar 22, 2024, 10:20:31 AMMar 22
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/17663464917@github.com>

Christian Brabandt

unread,
Apr 18, 2024, 6:08:21 PMApr 18
to vim/vim, vim-dev ML, Comment

I'm not sure, @RestorerZ explicitly asked for the encoding option. Bram also wasn't sure about it, but the encoding part is not the ugly bit of the code :-)

I don't like this and it will cause issues when we suddently have vim strings with different encodings. This is going to ask for trouble. Can we please get rid of this and always use utf-8?

The docs currently make it sound like one needs the Vim source to create a Messages.pot file? I am not sure if this is good or bad :/ as a plugin author I may not have the Vim source available, but on the other side, it may help to get started so 🤷


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2065410077@github.com>

cvwillegen

unread,
Apr 25, 2024, 2:48:08 AMApr 25
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 3 commits.

  • 509d996 Merge branch 'master' into add-gettext-package-argument
  • 0ccb5a1 Remove encoding argument.
  • 8602920 Merge branch 'master' into add-gettext-package-argument


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/18150261217@github.com>

cvwillegen

unread,
Apr 25, 2024, 7:07:57 AMApr 25
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/push/18154043158@github.com>

cvwillegen

unread,
Apr 25, 2024, 8:21:52 AMApr 25
to vim/vim, vim-dev ML, Comment

As far as I can see, I've fixed all remarks. The error on MacOS looks unrelated.


Reply to this email directly, view it on GitHub.
You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2077053114@github.com>

cvwillegen

unread,
Jun 6, 2024, 2:02:21 PMJun 6
to vim/vim, vim-dev ML, Comment

Hi Christian,

Anything else to do before this can be merged into the repo? Let me know!

Christ van Willegen


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2153105368@github.com>

Christian Brabandt

unread,
Jun 6, 2024, 2:10:38 PMJun 6
to vim/vim, vim-dev ML, Comment

ah sorry, I always wanted to come back here and then it slipped through. I'll go through this very soon. Good we updated it, so it is moved back to the top of the latest activity view :)


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2153118891@github.com>

Christian Brabandt

unread,
Jun 11, 2024, 3:47:24 PMJun 11
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In runtime/doc/repeat.txt:

> @@ -762,6 +765,29 @@ 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", getcwd()~"../lang")

that getcwd()~"../lang" looks wrong. I guess what is meant is more like this (assuming it should point to the lang directory in a directory just above where the current script is located)?

fnamemodify(expand("<script>"), ':p:h') .. '/../lang/')

In runtime/doc/builtin.txt:

> @@ -1169,6 +1172,13 @@ balloon_split({msg})					*balloon_split()*
 <		{only available when compiled with the |+balloon_eval_term|
 		feature}
 
+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.
⬇️ Suggested change
-		translations for a package.
+		translations for a package.  {path} should typically use the lang directory name see |package-create|

In runtime/doc/builtin.txt:

> @@ -1169,6 +1172,13 @@ balloon_split({msg})					*balloon_split()*
 <		{only available when compiled with the |+balloon_eval_term|
 		feature}
 
+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.
+
+		When {path} is omitted, the Vim runtime path is used.
⬇️ Suggested change
-		When {path} is omitted, the Vim runtime path is used.
+		When {path} is omitted, the $VIMRUNTIME/path is used.

In src/evalfunc.c:

> +    {
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+	prev = bind_textdomain_codeset((const char *)argvars[1].vval.v_string, (char *)p_enc);
+#endif
+
+#if defined(HAVE_DGETTEXT)
+	rettv->vval.v_string = vim_strsave((char_u *)dgettext((const char *)argvars[1].vval.v_string, (const char *)argvars[0].vval.v_string));
+#else
+	textdomain((const char *)argvars[1].vval.v_string);
+	rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
+	textdomain(VIMPACKAGE);
+#endif
+
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+	if (prev != NULL)
+	{

style, you can remove braces around single statements.


In src/evalfunc.c:

> +	textdomain((const char *)argvars[1].vval.v_string);
+	rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
+	textdomain(VIMPACKAGE);
+#endif
+
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+	if (prev != NULL)
+	{
+	    bind_textdomain_codeset((const char *)argvars[1].vval.v_string, prev);
+	}
+#endif
+    }
+    else
+    {
+	rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
+    }

style, remove braces


In src/evalfunc.c:

> @@ -6230,6 +6302,13 @@ f_has(typval_T *argvars, typval_T *rettv)
 		1
 #else
 		0
+#endif
+		},
+	{"bind_codeset",

This needs to be documented at :h feature-list in builtin.txt


In src/config.h.in:

> @@ -424,6 +423,12 @@
 /* Define if there is a working gettext(). */
 #undef HAVE_GETTEXT
 
+/* Define if there is a working bind_textdomain_codeset(). */
+#undef HAVE_BIND_TEXTDOMAIN_CODESET

Is there a missing configure check for this HAVE_BIND_TEXTDOMAIN_CODESET?


In src/testdir/test_gettext_cp1251.vim:

> @@ -0,0 +1,13 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+  if has('bind_codeset')
+    set encoding=cp1251

please don't change the encoding, perhaps you need :scriptencoding instead?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2111290339@github.com>

Christian Brabandt

unread,
Jun 12, 2024, 2:14:19 AMJun 12
to vim/vim, vim-dev ML, Comment

Oh, and can you please also update the vim script function descriptions and add the expected return type please?


Reply to this email directly, view it on GitHub.
You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2162184836@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:29:54 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.

  • a442378 Merge with latest master, fix feedback.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/before/0b9e142a5522bafa5b496853f197ce61370cf4e4/after/a442378c7c955e80701fec1048ca8f269d1a3259@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:31:00 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In runtime/doc/repeat.txt:

> @@ -762,6 +765,29 @@ 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", getcwd()~"../lang")

Added that, thanks for the pointer! Vim script is not my forte, I'm better at the C-side of things :-/


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122247000@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:32:14 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In runtime/doc/builtin.txt:

> @@ -1169,6 +1172,13 @@ balloon_split({msg})					*balloon_split()*
 <		{only available when compiled with the |+balloon_eval_term|
 		feature}
 
+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.

Added that. Also made the {path} parameter obligatory. It's nonsense to fall back to the $VIMRUNTIME path. If you want to get a string from there, just use gettext() without the package...


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122251534@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:32:34 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In runtime/doc/builtin.txt:

> @@ -1169,6 +1172,13 @@ balloon_split({msg})					*balloon_split()*
 <		{only available when compiled with the |+balloon_eval_term|
 		feature}
 
+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.
+
+		When {path} is omitted, the Vim runtime path is used.

{path} can no longer be omitted.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122252835@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:32:50 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/evalfunc.c:

> +    {
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+	prev = bind_textdomain_codeset((const char *)argvars[1].vval.v_string, (char *)p_enc);
+#endif
+
+#if defined(HAVE_DGETTEXT)
+	rettv->vval.v_string = vim_strsave((char_u *)dgettext((const char *)argvars[1].vval.v_string, (const char *)argvars[0].vval.v_string));
+#else
+	textdomain((const char *)argvars[1].vval.v_string);
+	rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
+	textdomain(VIMPACKAGE);
+#endif
+
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+	if (prev != NULL)
+	{

Ok.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122253431@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:32:58 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/evalfunc.c:

> +	textdomain((const char *)argvars[1].vval.v_string);
+	rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
+	textdomain(VIMPACKAGE);
+#endif
+
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+	if (prev != NULL)
+	{
+	    bind_textdomain_codeset((const char *)argvars[1].vval.v_string, prev);
+	}
+#endif
+    }
+    else
+    {
+	rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
+    }

Fixed as well.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122254144@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:34:05 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/config.h.in:

> @@ -424,6 +423,12 @@
 /* Define if there is a working gettext(). */
 #undef HAVE_GETTEXT
 
+/* Define if there is a working bind_textdomain_codeset(). */
+#undef HAVE_BIND_TEXTDOMAIN_CODESET

No, it was already there, but I moved it closer to the HAVE_GETTEXT and HAVE_DGETTEXT definitions (they are used together)


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122258713@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:35:15 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/testdir/test_gettext_cp1251.vim:

> @@ -0,0 +1,13 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+  if has('bind_codeset')
+    set encoding=cp1251

No, I really need to change the encoding, because the string is to be sent to the terminal after this. I re-set the encoding in the test file, though...


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122263214@github.com>

cvwillegen

unread,
Jun 17, 2024, 4:36:34 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Push

@cvwillegen pushed 1 commit.

  • 4a5ed02 Remove unsused variables.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12447/before/a442378c7c955e80701fec1048ca8f269d1a3259/after/4a5ed0283e14032ef568b703780585baef29cc08@github.com>

Christian Brabandt

unread,
Jun 17, 2024, 4:49:47 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/config.h.in:

> @@ -424,6 +423,12 @@
 /* Define if there is a working gettext(). */
 #undef HAVE_GETTEXT
 
+/* Define if there is a working bind_textdomain_codeset(). */
+#undef HAVE_BIND_TEXTDOMAIN_CODESET

I was talking about configure.ac. I only see a test for dgettext(), but not for bind_textdomain_codeset()?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122292776@github.com>

Christian Brabandt

unread,
Jun 17, 2024, 4:52:28 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/testdir/test_gettext_cp1251.vim:

> @@ -0,0 +1,13 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+  if has('bind_codeset')
+    set encoding=cp1251

Hm, IIRC, setting encoding in the active vim session may invalidate all stored string data. So this is really a bad idea to change the encoding.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122301694@github.com>

cvwillegen

unread,
Jun 17, 2024, 5:55:14 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/config.h.in:

> @@ -424,6 +423,12 @@
 /* Define if there is a working gettext(). */
 #undef HAVE_GETTEXT
 
+/* Define if there is a working bind_textdomain_codeset(). */
+#undef HAVE_BIND_TEXTDOMAIN_CODESET

It's in configure.ac#L4499. I didn't change that line...


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122454315@github.com>

Christian Brabandt

unread,
Jun 17, 2024, 5:58:06 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/config.h.in:

> @@ -424,6 +423,12 @@
 /* Define if there is a working gettext(). */
 #undef HAVE_GETTEXT
 
+/* Define if there is a working bind_textdomain_codeset(). */
+#undef HAVE_BIND_TEXTDOMAIN_CODESET

ah thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122458988@github.com>

cvwillegen

unread,
Jun 17, 2024, 6:00:00 AM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@cvwillegen commented on this pull request.


In src/testdir/test_gettext_cp1251.vim:

> @@ -0,0 +1,13 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+  if has('bind_codeset')
+    set encoding=cp1251

This is 'just' a test file. In the wild, you wouldn't change encoding on the fly (I expect this to be set in the user's (or system-wide!) .vimrc). But, I need to see that my changes work, and I see no other way to test this...

Always using UTF-8 isn't going to work if the user's terminal works in cp1251 (or does it???), and both you and Bram were against specifying the encoding specifically, so changing the encoding is the only way to test this change.

I'm happy to be proven wrong, though, since this is an 'ugly' bit of code, and hard to test without having a terminal (or language!) using these encodings.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/review/2122469603@github.com>

Christian Brabandt

unread,
Jun 17, 2024, 12:40:50 PM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

@RestorerZ can you please check it? Does this do what you want?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2173867271@github.com>

Restorer

unread,
Jun 19, 2024, 4:55:27 PM (7 days ago) Jun 19
to vim/vim, vim-dev ML, Comment

Yeah, basically, it works.
But there are a few things

  1. Christian, it bad that you removed support for the encoding parameter. It is possible that when you switch the encoding in running Vim, the translated text will not be displayed correctly. It should be checked.
  2. Conversion from plugin to js-file and POT file in Make_mvc.mak does not work (Macros as in Makefile have been added). I'll see what else I can do.
  3. very complicated make command to create a POT file. But there is probably no other way to do it.
    And a couple or three other nuances, but in general, as I said, it works wonderfully.

Unfortunately, other things are piling up right now (so I apologize for not responding right away), but I'll get them done and continue working on Vim.

Ubuntu22x64-2024-06-19-23-42-20.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2179445461@github.com>

Restorer

unread,
Jun 19, 2024, 6:10:25 PM (7 days ago) Jun 19
to vim/vim, vim-dev ML, Comment

It might be better to make a separate target for the make-files to prepare a POT file for plugins.
I'll have to make a note of what to do.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2179512754@github.com>

Christian Brabandt

unread,
Jun 20, 2024, 4:30:48 PM (6 days ago) Jun 20
to vim/vim, vim-dev ML, Comment

  • Christian, it bad that you removed support for the encoding parameter. It is possible that when you switch the encoding in running Vim, the translated text will not be displayed correctly. It should be checked.

  • Conversion from plugin to js-file and POT file in Make_mvc.mak does not work (Macros as in Makefile have been added). I'll see what else I can do.

  • very complicated make command to create a POT file. But there is probably no other way to do it.
    And a couple or three other nuances, but in general, as I said, it works wonderfully.

Well, the problem with 1) is, that I think Vim cannot handle character data with different encodings. I have no idea how this may break in all kind of funny ways. Let's not try to find this out. Also, you should never change the encoding of your running Vim instance, this may make all your existing character data invalid.

For 3) I am fully aware, but at least for now it seems not easily possible to simplify.

Okay then let me merge this and we can make further improvements in a followup PR then.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2181506565@github.com>

Christian Brabandt

unread,
Jun 20, 2024, 5:46:16 PM (6 days ago) Jun 20
to vim/vim, vim-dev ML, Comment

Closed #12447 via ce0ef91.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/issue_event/13234931030@github.com>

Christian Brabandt

unread,
Jun 20, 2024, 6:12:05 PM (6 days ago) Jun 20
to vim/vim, vim-dev ML, Comment

@cvwillegen I just merged it, but something must gone wrong. The test seems to pass for me locally, but in CI they seem to fail. Even when I run them interactively, it gettext('ERROR:', '__PACKAGE__') just returns ERROR for me


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2181640548@github.com>

Christian Brabandt

unread,
Jun 21, 2024, 1:33:53 AM (5 days ago) Jun 21
to vim/vim, vim-dev ML, Comment

I am disabling the test for now on MS-Windows and MacOS


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2182031975@github.com>

cvwillegen

unread,
Jun 21, 2024, 8:37:07 AM (5 days ago) Jun 21
to vim/vim, vim-dev ML, Comment

Op vr 21 jun. 2024 07:33 schreef Christian Brabandt <
***@***.***>:


> I am disabling the test for now on MS-Windows and MacOS
>

I pulled out my (spare) laptop, but that has OS 10.13.6, and there both
(all) gettext() tests succeed... not sure how to proceed.

Christ van Willegen

>


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2182672585@github.com>

LemonBoy

unread,
Jun 21, 2024, 9:46:01 AM (5 days ago) Jun 21
to vim/vim, vim-dev ML, Comment

I am disabling the test for now on MS-Windows and MacOS

On Windows you need to supply the libintl.dll (or libintl-8.dll) library somehow, the test runs fine once you do so.
You can download a copy from here.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2182786491@github.com>

Christian Brabandt

unread,
Jun 21, 2024, 10:11:40 AM (5 days ago) Jun 21
to vim/vim, vim-dev ML, Comment

Hm, so it seems we have libintl for mingw builds but just not for msvc builds then? I guess we could look at the vim-win32-installer repo, where we already use the libintl.dll.

I also noticed that the return value of gettext() and bindtext() may not be optimal. Perhaps it should return a number indicating success/failure?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2182833284@github.com>

cvwillegen

unread,
Jun 21, 2024, 10:52:56 AM (5 days ago) Jun 21
to vim/vim, vim-dev ML, Comment

Op vr 21 jun. 2024 16:11 schreef Christian Brabandt <
***@***.***>:


> I also noticed that the return value of gettext() and bindtext() may not
> be optimal. Perhaps it should return a number indicating success/failure?
>

dgettext() returns either the original (untranslated) msgid, or its
translation. Also, returning either True or a String would be a nightmare...

bindtextdomain() returns either NULL or the previous path that was set. We
could return True/False for success/ failure of memory allocation within
the function...

Christ van Willegen

>


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2182906475@github.com>

Christian Brabandt

unread,
Jun 22, 2024, 5:32:13 AM (4 days ago) Jun 22
to vim/vim, vim-dev ML, Comment

Yeah, we cannot change gettext() function. But for bindtextdomain() returning true false should be useful I think, at least better than nothing :)


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/12447/c2183959877@github.com>

Reply all
Reply to author
Forward
0 new messages