This PR adds the possibility to translate strings in packages using gettext("message", "package", "encoding").
Implements #11637
https://github.com/vim/vim/pull/12447
(8 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@zeertzjq commented on this pull request.
> @@ -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}]])
> @@ -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}])
> @@ -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()*
> @@ -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.
@cvwillegen pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.
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.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 2 commits.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 2 commits.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
Merging #12447 (c23e79b) into master (9f3afe7) will increase coverage by
0.64%
.
The diff coverage is13.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.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@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.
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.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 4 commits.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
is this ready?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
is this ready?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
@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.
@chrisbra commented on this pull request.
> @@ -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.
> + +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.
> +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.
@chrisbra commented on this pull request.
> @@ -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.
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.
@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.
@cvwillegen commented on this pull request.
> @@ -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.
> + +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.
@cvwillegen commented on this pull request.
> @@ -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.
@cvwillegen commented on this pull request.
> +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.
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.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
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.
@cvwillegen pushed 3 commits.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
@cvwillegen pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.
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.
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.
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.
@chrisbra commented on this pull request.
> @@ -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/')
> @@ -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|
> @@ -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.
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.
@cvwillegen pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.
@cvwillegen commented on this pull request.
> @@ -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.
@cvwillegen commented on this pull request.
> @@ -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.
> @@ -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.
@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.
> + 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.
@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.
@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.
@cvwillegen pushed 1 commit.
You are receiving this because you are subscribed to this thread.
@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.
@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.
@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.
@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.
@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.
@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.
Yeah, basically, it works.
But there are a few things
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.
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.
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.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.
@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.
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.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.
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.
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.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.
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.