blob: fbe474b949c28027f847a38cb5f20cfc0d2225e5 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001# Makefile for the Vim message translations.
2
Bram Moolenaare639eb42014-06-12 18:03:29 +02003# Include stuff found by configure.
4include ../auto/config.mk
5
Bram Moolenaara4a29342018-06-24 15:52:56 +02006# get LANGUAGES, MOFILES, MOCONVERTED and CHECKFILES
7include Make_all.mak
8
Bram Moolenaar071d4272004-06-13 20:20:40 +00009# Note: ja.sjis, *.cp1250 and zh_CN.cp936 are only for MS-Windows, they are
10# not installed on Unix
11
Bram Moolenaar071d4272004-06-13 20:20:40 +000012PACKAGE = vim
13SHELL = /bin/sh
Bram Moolenaar58d98232005-07-23 22:25:46 +000014VIM = ../vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000015
Yee Cheng Chin16110cc2023-03-16 21:04:31 +000016# MacOS sed is locale aware, set $LANG to avoid problems
17SED = LANG=C sed
18
Bram Moolenaar071d4272004-06-13 20:20:40 +000019# The OLD_PO_FILE_INPUT and OLD_PO_FILE_OUTPUT are for the new GNU gettext
20# tools 0.10.37, which use a slightly different .po file format that is not
21# compatible with Solaris (and old gettext implementations) unless these are
22# set. gettext 0.10.36 will not work!
Bram Moolenaare639eb42014-06-12 18:03:29 +020023MSGFMTCMD = OLD_PO_FILE_INPUT=yes $(MSGFMT) -v
Bram Moolenaar071d4272004-06-13 20:20:40 +000024XGETTEXT = OLD_PO_FILE_INPUT=yes OLD_PO_FILE_OUTPUT=yes xgettext
25MSGMERGE = OLD_PO_FILE_INPUT=yes OLD_PO_FILE_OUTPUT=yes msgmerge
26
27.SUFFIXES:
Bram Moolenaar58d98232005-07-23 22:25:46 +000028.SUFFIXES: .po .mo .pot .ck
Bram Moolenaara4a29342018-06-24 15:52:56 +020029.PHONY: all install uninstall prefixcheck converted check clean checkclean distclean update-po $(LANGUAGES)
Bram Moolenaar071d4272004-06-13 20:20:40 +000030
31.po.mo:
Bram Moolenaare639eb42014-06-12 18:03:29 +020032 $(MSGFMTCMD) -o $@ $<
Bram Moolenaar071d4272004-06-13 20:20:40 +000033
Bram Moolenaar58d98232005-07-23 22:25:46 +000034.po.ck:
Bram Moolenaar28c37952010-01-06 20:29:28 +010035 $(VIM) -u NONE -e -X -S check.vim -c "if error == 0 | q | endif" -c cq $<
Bram Moolenaar58d98232005-07-23 22:25:46 +000036 touch $@
37
Bram Moolenaar26096cc2019-04-11 15:25:40 +020038all: $(MOFILES) $(MOCONVERTED) $(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +000039
Bram Moolenaar58d98232005-07-23 22:25:46 +000040check: $(CHECKFILES)
41
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +020042# installing for real
Bram Moolenaarc4fba6f2013-01-17 13:37:32 +010043install: $(MOFILES) $(MOCONVERTED)
Bram Moolenaar58d98232005-07-23 22:25:46 +000044 @$(MAKE) prefixcheck
Bram Moolenaara4a29342018-06-24 15:52:56 +020045 for lang in $(LANGUAGES); do \
Bram Moolenaar071d4272004-06-13 20:20:40 +000046 dir=$(LOCALEDIR)/$$lang/; \
47 if test ! -x "$$dir"; then \
48 mkdir $$dir; chmod 755 $$dir; \
49 fi; \
50 dir=$(LOCALEDIR)/$$lang/LC_MESSAGES; \
51 if test ! -x "$$dir"; then \
52 mkdir $$dir; chmod 755 $$dir; \
53 fi; \
54 if test -r $$lang.mo; then \
55 $(INSTALL_DATA) $$lang.mo $$dir/$(PACKAGE).mo; \
56 chmod $(FILEMOD) $$dir/$(PACKAGE).mo; \
57 fi; \
58 done
59
60uninstall:
Bram Moolenaar58d98232005-07-23 22:25:46 +000061 @$(MAKE) prefixcheck
Bram Moolenaarc4fba6f2013-01-17 13:37:32 +010062 for cat in $(MOFILES) $(MOCONVERTED); do \
Bram Moolenaar071d4272004-06-13 20:20:40 +000063 cat=`basename $$cat`; \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +000064 lang=`echo $$cat | $(SED) 's/\$(CATOBJEXT)$$//'`; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000065 rm -f $(LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE).mo; \
66 done
67
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +020068# installing for local tryout into ../../runtime/lang
69tryoutinstall: $(MOFILES) $(MOCONVERTED)
70 @$(MAKE) prefixcheck
71 for lang in $(LANGUAGES); do \
72 dir=../../runtime/lang/$$lang/; \
73 if test ! -x "$$dir"; then \
74 mkdir $$dir; chmod 755 $$dir; \
75 fi; \
76 dir=../../runtime/lang/$$lang/LC_MESSAGES; \
77 if test ! -x "$$dir"; then \
78 mkdir $$dir; chmod 755 $$dir; \
79 fi; \
80 if test -r $$lang.mo; then \
81 cp $$lang.mo $$dir/$(PACKAGE).mo; \
82 chmod 644 $$dir/$(PACKAGE).mo; \
83 fi; \
84 done
85
Bram Moolenaarc4fba6f2013-01-17 13:37:32 +010086converted: $(MOCONVERTED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
Bram Moolenaar02938a92013-05-04 03:37:10 +020088# nl.po was added later, if it does not exist use a file with just a # in it
89# (an empty file doesn't work with old msgfmt).
Bram Moolenaar8d616172013-01-30 12:50:56 +010090nl.po:
Bram Moolenaar02938a92013-05-04 03:37:10 +020091 @( echo \# > nl.po )
Bram Moolenaar8d616172013-01-30 12:50:56 +010092
Bram Moolenaar28c37952010-01-06 20:29:28 +010093# Norwegian/Bokmal: "nb" is an alias for "no".
94# Copying the file is not efficient, but I don't know of another way to make
95# this work.
96nb.po: no.po
97 cp no.po nb.po
98
Bram Moolenaar071d4272004-06-13 20:20:40 +000099# Convert ja.po to create ja.sjis.po. Requires doubling backslashes in the
100# second byte. Don't depend on sjiscorr, it should only be compiled when
101# ja.sjis.po is outdated.
102ja.sjis.po: ja.po
103 @$(MAKE) sjiscorr
104 rm -f ja.sjis.po
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200105 iconv -f utf-8 -t cp932 ja.po | ./sjiscorr > ja.sjis.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107sjiscorr: sjiscorr.c
108 $(CC) -o sjiscorr sjiscorr.c
109
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200110ja.euc-jp.po: ja.po
111 iconv -f utf-8 -t euc-jp ja.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000112 $(SED) -e 's/charset=[uU][tT][fF]-8/charset=euc-jp/' -e 's/# Original translations/# Generated from ja.po, DO NOT EDIT/' > ja.euc-jp.po
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200113
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114# Convert cs.po to create cs.cp1250.po.
115cs.cp1250.po: cs.po
116 rm -f cs.cp1250.po
117 iconv -f iso-8859-2 -t cp1250 cs.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000118 $(SED) -e 's/charset=ISO-8859-2/charset=cp1250/' -e 's/# Original translations/# Generated from cs.po, DO NOT EDIT/' > cs.cp1250.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119
120# Convert pl.po to create pl.cp1250.po.
121pl.cp1250.po: pl.po
122 rm -f pl.cp1250.po
123 iconv -f iso-8859-2 -t cp1250 pl.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000124 $(SED) -e 's/charset=ISO-8859-2/charset=cp1250/' -e 's/# Original translations/# Generated from pl.po, DO NOT EDIT/' > pl.cp1250.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000126# Convert pl.po to create pl.UTF-8.po.
127pl.UTF-8.po: pl.po
128 rm -f pl.UTF-8.po
129 iconv -f iso-8859-2 -t utf-8 pl.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000130 $(SED) -e 's/charset=ISO-8859-2/charset=UTF-8/' -e 's/# Original translations/# Generated from pl.po, DO NOT EDIT/' > pl.UTF-8.po
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000131
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132# Convert sk.po to create sk.cp1250.po.
133sk.cp1250.po: sk.po
134 rm -f sk.cp1250.po
135 iconv -f iso-8859-2 -t cp1250 sk.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000136 $(SED) -e 's/charset=ISO-8859-2/charset=cp1250/' -e 's/# Original translations/# Generated from sk.po, DO NOT EDIT/' > sk.cp1250.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
Ada774e5572022-02-14 15:04:55 +0000138# Convert zh_CN.UTF-8.po to create zh_CN.po.
139zh_CN.po: zh_CN.UTF-8.po
140 rm -f zh_CN.po
141 iconv -f UTF-8 -t gb2312 zh_CN.UTF-8.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000142 $(SED) -e 's/charset=[uU][tT][fF]-8/charset=gb2312/' -e 's/# Original translations/# Generated from zh_CN.UTF-8.po, DO NOT EDIT/' > zh_CN.po
Ada774e5572022-02-14 15:04:55 +0000143
Bram Moolenaar16038d52017-01-27 20:37:49 +0100144# Convert zh_CN.UTF-8.po to create zh_CN.cp936.po.
145# Set 'charset' to gbk to avoid that msfmt generates a warning.
146# This used to convert from zh_CN.po, but that results in a conversion error.
147zh_CN.cp936.po: zh_CN.UTF-8.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148 rm -f zh_CN.cp936.po
Bram Moolenaar16038d52017-01-27 20:37:49 +0100149 iconv -f UTF-8 -t cp936 zh_CN.UTF-8.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000150 $(SED) -e 's/charset=[uU][tT][fF]-8/charset=gbk/' -e 's/# Original translations/# Generated from zh_CN.UTF-8.po, DO NOT EDIT/' > zh_CN.cp936.po
151
152# Convert zh_TW.UTF-8.po to create zh_TW.po
153zh_TW.po: zh_TW.UTF-8.po
154 rm -f zh_TW.po
155 iconv -f UTF-8 -t big5 zh_TW.UTF-8.po | \
156 $(SED) -e 's/charset=[uU][tT][fF]-8/charset=big5/' -e 's/# Original translations/# Generated from zh_TW.UTF-8.po, DO NOT EDIT/' > zh_TW.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000157
Bram Moolenaar5e3dae82010-03-02 16:19:40 +0100158# Convert ko.UTF-8.po to create ko.po.
159ko.po: ko.UTF-8.po
160 rm -f ko.po
161 iconv -f UTF-8 -t euc-kr ko.UTF-8.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000162 $(SED) -e 's/charset=UTF-8/charset=euc-kr/' \
Bram Moolenaar5e3dae82010-03-02 16:19:40 +0100163 -e 's/# Korean translation for Vim/# Generated from ko.UTF-8.po, DO NOT EDIT/' \
164 > ko.po
165
Bram Moolenaar071d4272004-06-13 20:20:40 +0000166# Convert ru.po to create ru.cp1251.po.
167ru.cp1251.po: ru.po
168 rm -f ru.cp1251.po
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000169 iconv -f utf-8 -t cp1251 ru.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000170 $(SED) -e 's/charset=[uU][tT][fF]-8/charset=cp1251/' -e 's/# Original translations/# Generated from ru.po, DO NOT EDIT/' > ru.cp1251.po
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000172# Convert uk.po to create uk.cp1251.po.
173uk.cp1251.po: uk.po
174 rm -f uk.cp1251.po
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000175 iconv -f utf-8 -t cp1251 uk.po | \
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000176 $(SED) -e 's/charset=[uU][tT][fF]-8/charset=cp1251/' -e 's/# Original translations/# Generated from uk.po, DO NOT EDIT/' > uk.cp1251.po
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000177
Bram Moolenaar58d98232005-07-23 22:25:46 +0000178prefixcheck:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179 @if test "x" = "x$(prefix)"; then \
180 echo "******************************************"; \
181 echo " please use make from the src directory "; \
182 echo "******************************************"; \
183 exit 1; \
184 fi
185
Bram Moolenaar316059c2006-01-14 21:18:42 +0000186clean: checkclean
187 rm -f core core.* *.old.po *.mo *.pot sjiscorr
Bram Moolenaard0380dc2019-06-05 21:25:34 +0200188 rm -f LINGUAS vim.desktop gvim.desktop tmp_*desktop
Bram Moolenaar071d4272004-06-13 20:20:40 +0000189
190distclean: clean
191
Bram Moolenaar316059c2006-01-14 21:18:42 +0000192checkclean:
193 rm -f *.ck
194
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200195PO_INPUTLIST = \
196 ../*.c \
197 ../if_perl.xs \
198 ../GvimExt/gvimext.cpp \
Bram Moolenaarfa573352020-09-04 13:53:00 +0200199 ../errors.h \
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200200 ../globals.h \
201 ../if_py_both.h \
202 ../vim.h \
203 gvim.desktop.in \
204 vim.desktop.in
205
206PO_VIM_INPUTLIST = \
Bram Moolenaar65b34862023-05-10 14:47:50 +0100207 ../../runtime/optwin.vim \
208 ../../runtime/defaults.vim
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200209
210PO_VIM_JSLIST = \
Bram Moolenaar65b34862023-05-10 14:47:50 +0100211 optwin.js \
212 defaults.js
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200213
214$(PACKAGE).pot: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST)
215 # Convert the Vim scripts to (what looks like) Javascript
216 $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
217 # create vim.pot
218 $(XGETTEXT) --default-domain=$(PACKAGE) --add-comments \
219 --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 \
220 $(PO_INPUTLIST) $(PO_VIM_JSLIST)
221 mv -f $(PACKAGE).po $(PACKAGE).pot
222 # Fix Vim scripts names, so that "gf" works
Bram Moolenaarfa573352020-09-04 13:53:00 +0200223 $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST)
Bram Moolenaar0b39c3f2020-08-30 15:52:10 +0200224 # Delete the temporary files
225 rm *.js
Bram Moolenaar071d4272004-06-13 20:20:40 +0000226
Bram Moolenaar12e91862019-05-03 21:20:03 +0200227vim.desktop: vim.desktop.in $(POFILES)
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000228 echo $(LANGUAGES) | tr " " "\n" |$(SED) -e '/\./d' | sort > LINGUAS
Bram Moolenaard0380dc2019-06-05 21:25:34 +0200229 $(MSGFMT) --desktop -d . --template vim.desktop.in -o tmp_vim.desktop
Bram Moolenaar91882cf2019-05-05 21:01:51 +0200230 rm -f LINGUAS
Bram Moolenaard0380dc2019-06-05 21:25:34 +0200231 if command -v desktop-file-validate; then desktop-file-validate tmp_vim.desktop; fi
232 mv tmp_vim.desktop vim.desktop
Bram Moolenaar12e91862019-05-03 21:20:03 +0200233
Bram Moolenaar2ecbe532022-07-29 21:36:21 +0100234# The dependency on vim.desktop is only to avoid the two targets are build at
235# the same time, which causes a race for the LINGUAS file.
236gvim.desktop: gvim.desktop.in $(POFILES) vim.desktop
Yee Cheng Chin16110cc2023-03-16 21:04:31 +0000237 echo $(LANGUAGES) | tr " " "\n" |$(SED) -e '/\./d' | sort > LINGUAS
Bram Moolenaard0380dc2019-06-05 21:25:34 +0200238 $(MSGFMT) --desktop -d . --template gvim.desktop.in -o tmp_gvim.desktop
Bram Moolenaar91882cf2019-05-05 21:01:51 +0200239 rm -f LINGUAS
Bram Moolenaard0380dc2019-06-05 21:25:34 +0200240 if command -v desktop-file-validate; then desktop-file-validate tmp_gvim.desktop; fi
241 mv tmp_gvim.desktop gvim.desktop
Bram Moolenaara60e5362019-04-11 13:11:39 +0200242
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000243update-po: $(LANGUAGES)
244
Bram Moolenaar071d4272004-06-13 20:20:40 +0000245# Don't add a dependency here, we only want to update the .po files manually
246$(LANGUAGES):
247 @$(MAKE) $(PACKAGE).pot
248 if test ! -f $@.po.orig; then cp $@.po $@.po.orig; fi
249 mv $@.po $@.po.old
250 if $(MSGMERGE) $@.po.old $(PACKAGE).pot -o $@.po; then \
251 rm -f $@.po.old; \
252 else \
253 echo "msgmerge for $@.po failed!"; mv $@.po.old $@.po; \
254 fi