Skip to content

Commit

Permalink
Merge pull request #929 from mattias-p/update-po
Browse files Browse the repository at this point in the history
Replace "make xx.po" with a script
  • Loading branch information
mattias-p committed Jun 24, 2021
2 parents 2e429fa + c1cb2f0 commit aba20e9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ sub MY::postamble {
# Make FreeBSD use gmake for share/Makefile
$text = 'GMAKE ?= "gmake"' . "\n"
. 'pure_all :: share/Makefile' . "\n"
. "\t" . 'cd share && $(GMAKE) touch-po all' . "\n";
. "\t" . 'cd share && $(GMAKE) all' . "\n";
} else {
$text = 'pure_all :: share/Makefile' . "\n"
. "\t" . 'cd share && $(MAKE) touch-po all' . "\n";
. "\t" . 'cd share && $(MAKE) all' . "\n";
};
return $text;
};
Expand Down
13 changes: 7 additions & 6 deletions docs/Translation-translators.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Currently there are the following files (and languages):
* nb.po (Norwegian)
* sv.po (Swedish)

Execute `make xx.po` to update the *PO* file for language "xx".
Execute `./update-po xx.po` to update the *PO* file for language
"xx".
Choose the language code for the language that you want to update.
The command will update the *PO* file with new message ids (*msgid*) from the
source code.
Expand All @@ -78,8 +79,8 @@ ids based on fuzzy matching of similar strings. This is not always desirable
and you can disable fuzzy matching by executing one of the following
commands instead:
```
make xx.po MSGMERGE_OPTS=--no-fuzzy-mathing
make update-po MSGMERGE_OPTS=--no-fuzzy-mathing
make update-po MSGMERGE_OPTS=--no-fuzzy-matching POFILES=xx.po
make update-po MSGMERGE_OPTS=--no-fuzzy-matching
```

## Github preparation
Expand Down Expand Up @@ -167,7 +168,7 @@ welcome comments on these.
language code in question. This should be done every time.
```
cd share
make xx.po
./update-po xx.po
```

* The *PO* file is updated with new *msgids*, if any, and now you can start
Expand Down Expand Up @@ -272,7 +273,7 @@ steps before this step:
> to work with. Replace "xx" with the language code in question.
> ```
> cd share
> make xx.po
> ./update-po xx.po
> ```
The new language is not there and cannot be updated. Instead you have to
Expand All @@ -293,7 +294,7 @@ of an existing file.
for Swedish.
```
cd share
make sv.po
./update-po sv.po
cp sv.po xx.po
git checkout sv.po
```
Expand Down
11 changes: 3 additions & 8 deletions share/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.POSIX:
.SUFFIXES: .po .mo
.PHONY: all check-msg-args dist extract-pot tidy-po show-fuzzy touch-po update-po
.PHONY: all check-msg-args dist extract-pot tidy-po show-fuzzy update-po

POFILES := $(shell find . -maxdepth 1 -type f -name '*.po' -exec basename {} \;)
MOFILES := $(POFILES:%.po=%.mo)
Expand All @@ -20,19 +20,14 @@ tidy-po:
trap 'rm -rf "$$tmpdir"' EXIT ;\
for f in $(POFILES) ; do msgcat $$f -o $$tmpdir/$$f && mv -f $$tmpdir/$$f $$f ; done

touch-po:
@touch $(POTFILE) $(POFILES)

update-po: extract-pot $(POFILES)
update-po: extract-pot
@for f in $(POFILES) ; do msgmerge --update --backup=none --quiet --no-location $(MSGMERGE_OPTS) $$f $(POTFILE) ; done

extract-pot:
@xgettext --output $(POTFILE) --sort-by-file --add-comments --language=Perl --from-code=UTF-8 -k__ -k\$$__ -k%__ -k__x -k__n:1,2 -k__nx:1,2 -k__xn:1,2 -kN__ -kN__n:1,2 -k__p:1c,2 -k__np:1c,2,3 -kN__p:1c,2 -kN__np:1c,2,3 $(PMFILES)

$(POTFILE): extract-pot

$(POFILES): $(POTFILE)
@msgmerge --update --backup=none --quiet --no-location $(MSGMERGE_OPTS) $@ $(POTFILE)

.po.mo:
@msgfmt -o $@ $<
@mkdir -p locale/`basename $@ .mo`/LC_MESSAGES
Expand Down
9 changes: 9 additions & 0 deletions share/update-po
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ -z "$1" ] ; then
echo "error: No PO file specified." >&2
exit 2
fi
po_file="$1" ; shift

make update-po POFILES="$po_file"

0 comments on commit aba20e9

Please sign in to comment.