1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
# po/Makefile.am for anaconda
#
# Based loosely on Makefiles generated by gettext
#
# Copyright (C) 2016 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: David Shea <dshea@redhat.com>
# This file is intended to replace everything that gettextize or autopoint
# installs. It has a lot less weird crud and tries to cooperate with
# automake at least a little bit.
#
# To use it:
# - Edit COPYRIGHT_HOLDER and MSGID_BUGS_ADDRESS below
#
# - Add the file types you're interested in to POTFILE_SUFFIXES. This replaces
# the old POTFILES.in since the list of files you want to select for
# translation is invariably all of them.
#
# - Add po/Makefile to AC_CONFIG_FILES (there may be po/Makefile.in if
# switching from gettextize, replace that)
#
# - Get rid of AM_GNU_GETTEXT and AM_GNU_GETTEXT_VERSION. You might want to
# add checks for xgettext, msgmerge, msgfmt, and msgcat. Up to you.
#
# - Add the following to .gitignore:
# po/*.mo
# po/*.po
# po/*.mpo
# po/*.pot
#
# - Remove everything in the po/ directory from source control except this
# file.
#
# The idea is something like this:
# From a clean project, you do the automake stuff and download a bunch of
# .po files from the external translation site. These are the "source" files.
#
# From the source tree we create a template file, <package>.pot, of all the
# translatable strings. This file is not saved or distributed because there's
# really no reason to do that if translations are not part of the source
# tree. The file is pushed to the translators when creating a new release,
# and it is used during the build, and that's it.
#
# The .po files might not match the .pot file, because this is the nature of
# linear time and translations being a separate task. Maybe the translator
# last touched the .po file yesterday. Maybe three years ago. To get the
# translations in sync with the source, which usually means untranslating
# some strings, we run msgmerge on all of the source files. The merged files
# are saved in builddir as <lang>.mpo, which is a non-standard file extension
# I just made up.
#
# The merged .po files are then compiled into .mo files, which are what
# get installed to /usr/share/locale.
# Variables used in xgettext arguments
COPYRIGHT_HOLDER = Red Hat, Inc.
MSGID_BUGS_ADDRESS = vtrefny@redhat.com
# What kind of files are we looking for?
POTFILE_SUFFIXES = c
# Below this line is the part that shouldn't need to be changed for other
# projects
# Turn POTFILE_SUFFIXES into a list of files
POTFILE_INPUT = $(foreach s,$(POTFILE_SUFFIXES),\
$(shell find $(top_srcdir)/ -type d -name .git -prune -o -type f -name '*.$(s)' -print))
# The template file, generated by from all files with translatable strings.
POTFILE = $(PACKAGE).pot
# The translation files, provided by translators, pulled down from Zanata.
# Use whatever we got from Zanata, or nothing at all if no translations were
# pulled.
POFILES = $(wildcard $(srcdir)/*.po)
# The translations files after they have been merged with the latest copy of
# the .pot file. These are written to $(builddir) as <lang>.mpo.
MERGED_POFILES = $(patsubst %.po,%.mpo,$(notdir $(POFILES)))
# The MO files, which are the binary data built from the .po files.
MOFILES = $(patsubst %.mpo,%.mo,$(MERGED_POFILES))
# Special weirdness to auto-generate sr@latin.po if sr.po is present
MERGED_POFILES += $(if $(shell [ -f sr.po ] && echo y),sr@latin.mpo,)
sr@latin.mpo: $(srcdir)/sr.po
$(AM_V_GEN)$(MSGFILTER) -i $(srcdir)/sr.po -o $@ recode-sr-latin
# The gettext programs and arguments
# xgettext eXtracts strings from translatable files and generates the template
# (.pot) file. We use a wrapper from translation-canary in order to catch
# warnings about strings that may not be translatable, and all the keyword
# arguments define the various functions that are used to mark a string as
# translatable
XGETTEXT = $(top_srcdir)/translation-canary/xgettext_werror.sh
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=P_:1,2 \
--keyword=C_:1c,2 --keyword=CN_:1c,2 --keyword=CP_:1c,2,3 \
--add-comments=TRANSLATORS: \
--from-code=UTF-8 --package-name=$(PACKAGE) \
--package-version=$(PACKAGE_VERSION) \
--copyright-holder="$(COPYRIGHT_HOLDER)" \
--msgid-bugs-address="$(MSGID_BUGS_ADDRESS)"
# msgfmt compiles a .po file into a .mo file
# Do not include --check in the options, since those checks are more
# conveniently done by translation-canary
MSGFMT = msgfmt
MSGFMT_OPTIONS =
# msgmerge merges changes in the template (.pot) file back into the translation
# (.po) file
MSGMERGE = msgmerge
MSGMERGE_OPTIONS =
# msgfilter applies a filter to a .po file. We use this to automatically
# transliterate Serbian from Cyrillic (sr) to Latin (sr@latin).
MSGFILTER = msgfilter
# msgcat cats multiple .po (or .pot) files together. We use this to generate
# the .pot file from multiple parts.
MSGCAT = msgcat
# Automake magic for verbose/non-verbose build output
GETTEXT_V_EXTRACT = $(GETTEXT_V_EXTRACT_$(V))
GETTEXT_V_EXTRACT_ = $(GETTEXT_V_EXTRACT_$(AM_DEFAULT_VERBOSITY))
GETTEXT_V_EXTRACT_0 = @echo " EXTRACT " $@;
GETTEXT_V_FORMAT = $(GETTEXT_V_FORMAT_$(V))
GETTEXT_V_FORMAT_ = $(GETTEXT_V_FORMAT_$(AM_DEFAULT_VERBOSITY))
GETTEXT_V_FORMAT_0 = @echo " FORMAT " $@;
GETTEXT_V_MERGE = $(GETTEXT_V_MERGE_$(V))
GETTEXT_V_MERGE_ = $(GETTEXT_V_MERGE_$(AM_DEFAULT_VERBOSITY))
GETTEXT_V_MERGE_0 = @echo " MERGE " $@;
# If make was run with V=1, add verbose options to msgfmt
MSGFMT_V_OPTIONS = $(MSGFMT_V_OPTIONS_$(V))
MSGFMT_V_OPTIONS_ = $(MSGFMT_V_OPTIONS_$(AM_DEFAULT_VERBOSITY))
MSGFMT_V_OPTIONS_0 = $(MSGFMT_OPTIONS)
MSGFMT_V_OPTIONS_1 = $(MSGFMT_OPTIONS) --statistics --verbose
# Same with msgmerge
MSGMERGE_V_OPTIONS = $(MSGMERGE_V_OPTIONS_$(V))
MSGMERGE_V_OPTIONS_ = $(MSGMERGE_V_OPTIONS_$(AM_DEFAULT_VERBOSITY))
MSGMERGE_V_OPTIONS_0 = $(MSGMERGE_OPTIONS) --quiet
MSGMERGE_V_OPTIONS_1 = $(MSGMERGE_OPTIONS) --verbose
# Actually do stuff:
# .po files get distributed but not installed
dist_noinst_DATA = $(POFILES) $(POTFILE)
# Build the .mo files but don't actually do anything with them. The real
# install part is in the install-data-local target below. Build the .pot file
# as well, even if there are no .mo files to build, so it can be tested.
nodist_noinst_DATA = $(MOFILES)
# How to build the .pot file. This needs to be regenerated if anything that
# goes into it has changed.
$(POTFILE): $(POTFILE_INPUT)
$(GETTEXT_V_EXTRACT)$(XGETTEXT) $(XGETTEXT_OPTIONS) --directory=$(top_srcdir) -o $@ \
$(patsubst $(top_srcdir)/%,%,$(POTFILE_INPUT))
# Force a rebuild of the .pot file. Useful if something got removed, for
# example.
$(PACKAGE).pot-update:
@rm -f $(POTFILE)
@$(MAKE) $(POTFILE)
# How to build the merged .mpo files from the .po files
$(MERGED_POFILES): $(POFILES)
.po.mpo:
$(GETTEXT_V_MERGE)$(MSGMERGE) $(MSGMERGE_V_OPTIONS) -o $@ $< $(top_srcdir)/po/$(POTFILE)
# How to build the .mo files from the .mpo files
$(MOFILES): $(MERGED_POFILES) $(POTFILE)
.mpo.mo:
$(GETTEXT_V_FORMAT)$(MSGFMT) $(MSGFMT_V_OPTIONS) -o $@ $<
# Install the .mo files.
# .mo files get installed as $datadir/locale/<lang>/LC_MESSAGES/<package>.po
# which doesn't really fit well with the way make or automake do things but
# that is the world we live in
localedir = $(datadir)/locale
install-data-local:
@for mo in $(MOFILES) ; do \
lang="$$(basename "$$mo" .mo)" ; \
$(MKDIR_P) $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES || exit $$? ; \
$(INSTALL_DATA) "$$mo" "$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE).mo" || exit $$? ; \
done
uninstall-local:
@for mo in $(MOFILES) ; do \
lang="$$(basename "$$mo" .mo)" ; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE).mo ; \
done
CLEANFILES = $(MERGED_POFILES) $(MOFILES)
|