patch 9.1.0509: not possible to translate Vim script messages
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>
diff --git a/src/po/Make_all.mak b/src/po/Make_all.mak
index ac11228..c3e6459 100644
--- a/src/po/Make_all.mak
+++ b/src/po/Make_all.mak
@@ -189,8 +189,8 @@
../../runtime/defaults.vim
PO_VIM_JSLIST = \
- optwin.js \
- defaults.js
+ ________runtime__optwin.js \
+ ________runtime__defaults.js
# Arguments for xgettext to pick up messages to translate from the source code.
XGETTEXT_KEYWORDS = --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 --keyword=PLURAL_MSG:2,4
diff --git a/src/po/Makefile b/src/po/Makefile
index cc4008f..87d657b 100644
--- a/src/po/Makefile
+++ b/src/po/Makefile
@@ -1,17 +1,18 @@
# Makefile for the Vim message translations.
+PO_BASEDIR = .
# Include stuff found by configure.
-include ../auto/config.mk
+include $(PO_BASEDIR)/../auto/config.mk
# Get LANGUAGES, MOFILES, MOCONVERTED and others.
-include Make_all.mak
+include $(PO_BASEDIR)/Make_all.mak
# Note: ja.sjis, *.cp1250 and zh_CN.cp936 are only for MS-Windows, they are
# not installed on Unix.
PACKAGE = vim
SHELL = /bin/sh
-VIM = ../vim
+VIM = $(PO_BASEDIR)/../vim
# MacOS sed is locale aware, set $LANG to avoid problems.
SED = LANG=C sed
@@ -261,13 +262,13 @@
$(PACKAGE).pot: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST)
# Convert the Vim scripts to (what looks like) Javascript.
- $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
+ $(VIM) -u NONE --not-a-term -S $(PO_BASEDIR)/tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
# Create vim.pot.
$(XGETTEXT) --default-domain=$(PACKAGE) --add-comments \
$(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST)
mv -f $(PACKAGE).po $(PACKAGE).pot
# Fix Vim scripts names, so that "gf" works.
- $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
+ $(VIM) -u NONE --not-a-term -S $(PO_BASEDIR)/fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
# Delete the temporary files.
rm *.js
diff --git a/src/po/fixfilenames.vim b/src/po/fixfilenames.vim
index 04bc079..c92839e 100644
--- a/src/po/fixfilenames.vim
+++ b/src/po/fixfilenames.vim
@@ -4,7 +4,7 @@
set shortmess+=A
for name in argv()[1:]
- let jsname = fnamemodify(name, ":t:r") .. ".js"
+ let jsname = fnamemodify(name, ":r:gs?\\~?_?:gs?\\.?_?:gs?/?__?:gs?\\?__?") .. ".js"
exe "%s+" .. jsname .. "+" .. substitute(name, '\\', '/', 'g') .. "+"
endfor
diff --git a/src/po/tojavascript.vim b/src/po/tojavascript.vim
index 8b0dd73..32eea9b 100644
--- a/src/po/tojavascript.vim
+++ b/src/po/tojavascript.vim
@@ -13,7 +13,7 @@
g/^\s*set .*"/s/.*//
" Write as .js file, xgettext recognizes them
- exe 'w! ' .. fnamemodify(name, ":t:r") .. ".js"
+ exe 'w! ' .. fnamemodify(name, ":r:gs?\\~?_?:gs?\\.?_?:gs?/?__?:gs?\\?__?") .. ".js"
endfor
quit