Skip to content

Commit

Permalink
add gettext translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann Büchau committed Jun 10, 2017
1 parent 75f2886 commit 8035f01
Show file tree
Hide file tree
Showing 13 changed files with 1,050 additions and 112 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ debian/files
*.debhelper

# temporary files
tmp*
temp*
*.tmp
*.temp

Expand All @@ -18,6 +20,10 @@ debian/files
*.scan
config.status

# gettext
*.mo
*.pot

# instantiated template files
Makefile
bin/uca-apply
Expand Down
71 changes: 63 additions & 8 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ psdir:=@psdir@

# binaries
make_bin:=@make_bin@
find_bin:=@find_bin@
xdg_open_bin:=@xdg_open_bin@
convert_bin:=@convert_bin@
su_bin:=@su_bin@
xargs_bin:=@xargs_bin@
find_bin:=@find_bin@
perl_bin:=@perl_bin@
gpg2_bin:=@gpg2_bin@
zenity_bin:=@zenity_bin@
Expand All @@ -64,6 +64,11 @@ gs_bin:=@gs_bin@
m4_bin:=@m4_bin@
pandoc_bin:=@pandoc_bin@
python3_bin:=@python3_bin@
gettext_bin:=@gettext_bin@
gettextsh_bin:=@gettextsh_bin@
xgettext_bin:=@xgettext_bin@
msgfmt_bin:=@msgfmt_bin@
msgmerge_bin:=@msgmerge_bin@

PACKAGE_VERSION := @PACKAGE_VERSION@
PACKAGE_NAME := @PACKAGE_NAME@
Expand All @@ -72,8 +77,28 @@ PACKAGE_STRING := @PACKAGE_STRING@
configure_dirs = bindir sbindir libexecdir sysconfdir sharedstatedir \
localstatedir runstatedir libdir includedir oldincludedir datarootdir \
datadir infodir localedir mandir docdir htmldir dvidir pdfdir psdir
configure_vars = $(configure_dirs) PACKAGE_VERSION PACKAGE_STRING PACKAGE_NAME \
PACKAGE_URL
configure_vars = $(configure_dirs) \
PACKAGE_VERSION PACKAGE_STRING PACKAGE_NAME PACKAGE_URL \
PASSWDFILE UCAFILE \
make_bin \
xdg_open_bin \
convert_bin \
su_bin \
xargs_bin \
find_bin \
perl_bin \
gpg2_bin \
zenity_bin \
bc_bin \
gs_bin \
m4_bin \
pandoc_bin \
python3_bin \
gettext_bin \
gettextsh_bin \
xgettext_bin \
msgfmt_bin \
msgmerge_bin

$(foreach configure_dir,$(configure_dirs),\
$(eval $(configure_dir) := $(abspath $(DESTDIR)/$($(configure_dir)))))
Expand All @@ -87,8 +112,10 @@ $(foreach configure_dir,$(configure_dirs),\
local_mandir = man
local_bindir = bin
local_datarootdir = share
local_localedir = locale

local_dirs = $(local_mandir) $(local_bindir) $(local_datarootdir)
local_dirs = $(local_mandir) $(local_bindir) $(local_datarootdir) \
$(local_localedir)

installed_files_file = installed_files.tmp

Expand All @@ -102,12 +129,12 @@ UCA_XML_FILES_M4 = $(wildcard $(local_system_uca_dir)/*.xml.m4 )
UCA_XML_FILES = $(UCA_XML_FILES_M4:.m4=)
# m4
M4_INCL = m4
tuca_include_m4 = $(M4_INCL)/tuca.m4

# pandoc options for manpage creation
PANDOCOPTS = -f markdown -t man --standalone

# no need to to do further replacement elsewhere
# IN_FILES = $(shell $(find_bin) $(local_dirs) -type f -iname '*.in')
IN_FILES = $(shell $(find_bin) $(local_dirs) $(M4_INCL) -type f -iname '*.in')
IN_FILES_INSTANTIATED = $(IN_FILES:.in=)

CONFIGURE_AC = configure.ac
Expand All @@ -117,11 +144,20 @@ CONFIGURE = configure
DEBIAN_CHANGELOG = debian/changelog
DEBIAN_CHANGELOG_VERSION = $(shell $(perl_bin) -ne 'if(s/^$(PACKAGE_NAME)\s*\((.*?)\).*$$/$$1/g){print;exit}' $(DEBIAN_CHANGELOG))

only_uca_cmd_file = $(local_localedir)/tmp_only_uca_commands.sh
# all pofiles
POFILES = $(shell find $(local_localedir) -type f -iname '*.po')
# the corresponding mofiles
MOFILES = $(POFILES:.po=.mo)
# temporary pot-file template
POTFILE = $(local_localedir)/$(PACKAGE_NAME).pot

# default target
.PHONY: all
all: $(IN_FILES_INSTANTIATED) $(UCA_XML_FILES) $(CONFIGURE) $(CONFIGURE_AC) $(GFMANPAGES)
all: $(MOFILES) $(IN_FILES_INSTANTIATED) $(UCA_XML_FILES) $(CONFIGURE) \
$(CONFIGURE_AC) $(GFMANPAGES)

%: %.m4 $(wildcard $(M4_INCL)/*.m4)
%: %.m4 $(tuca_include_m4) $(wildcard $(M4_INCL)/*.m4)
$(m4_bin) -I $(M4_INCL) $< > $@

# create rule to install a FILE into the TARGET_DIRECTORY
Expand All @@ -141,6 +177,7 @@ find_opts = -not -type d -not -iname '*.in'
# define the local content that is to install
local_datarootdir_toinstall = $(shell $(find_bin) $(local_datarootdir) $(find_opts) -not -iname '*.m4')
local_mandir_toinstall = $(GFMANPAGES)
local_localedir_toinstall = $(MOFILES)
local_bindir_toinstall = $(shell $(find_bin) $(local_bindir) $(find_opts))

# set up install rules for all configure directories
Expand All @@ -167,6 +204,23 @@ $(CONFIGURE_AC): $(DEBIAN_CHANGELOG)
$(IN_FILES_INSTANTIATED): % : %.in Makefile
$(perl_bin) -pe '$(foreach var,$(configure_vars),s#[@]$(var)[@]#$($(var))#g;)' < $< > $@

### translations ###
$(only_uca_cmd_file): $(UCA_XML_FILES) | $(patsubst %/,%,$(dir $(only_uca_cmd_file)))
cat $^ | $(perl_bin) -ne 'print if s#<command[^>]*>\s*(.*?)\s*</command>#$$1#g' > $@

# create the pot-file with all translatable strings from the srcfiles
$(POTFILE): $(only_uca_cmd_file)
$(xgettext_bin) -L Shell -o $@ $^

# update the translated catalog
%.po: $(POTFILE)
VERSION_CONTROL=off $(msgmerge_bin) -U --backup=off $@ $<
touch $@ # make sure timestamp was updated

# compile the translations
%.mo: %.po
$(msgfmt_bin) -o $@ $<

.PHONY: bin_executable
bin_executable: $(local_bindir_toinstall)
for file in $^;do chmod +x $$file;done
Expand Down Expand Up @@ -201,6 +255,7 @@ clean:
rm -f $(UCA_XML_FILES)
rm -f $(GFMANPAGES)
rm -f $(installed_files_file)
rm -f $(only_uca_cmd_file)



6 changes: 1 addition & 5 deletions bin/uca-apply.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/make -f

# install architecture-independent files in PREFIX [/usr/local]
prefix:=@prefix@
# install architecture-dependent files in EPREFIX [PREFIX]
exec_prefix:=@exec_prefix@
# user executables [EPREFIX/bin]
bindir:=@bindir@
# system admin executables [EPREFIX/sbin]
Expand Down Expand Up @@ -43,7 +39,7 @@ dvidir:=@dvidir@
# pdf documentation [DOCDIR]
pdfdir:=@pdfdir@
# ps documentation [DOCDIR]
psdir:=${docdir}
psdir:=@docdir@

# programs
make_bin:=@make_bin@
Expand Down
Loading

0 comments on commit 8035f01

Please sign in to comment.