Last active
April 1, 2016 13:50
-
-
Save olebedev/2961f79a9bfacb368f8f to your computer and use it in GitHub Desktop.
Makefile rule to extract gettetx/ngettext calls from Golang templates and source files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XGETTEXT_FLAGS = --no-wrap --language=c --from-code=UTF-8 --output=- - | |
$(POT_FILE): $(TEMPLATES) $(filter-out $(BINDATA), $(GO_FILES)) | |
@cat $? \ | |
| grep -i gettext \ | |
| sed -e "s/ngettext \"\([^\"]*\)\".\"\([^\"]*\)\".\(.*\) }}/ngettext(\"\1\", \"\2\", \3) }}/g" \ | |
| sed -e "s/[^n]gettext \"\(.*\)\"/ gettext(\"\1\")/g" \ | |
| sed -e "s/NGetText(\([^\)]*\))/ ngettext(\1) /g" \ | |
| sed -e "s/GetText(\([^\)]*\))/ gettext(\1) /g" \ | |
| xgettext $(XGETTEXT_FLAGS) \ | |
| sed -e '1,20d' \ | |
| msguniq > $@ | |
%.po: $(POT_FILE) | |
@msgmerge -U $@ $< | |
.INTERMEDIATE: $(POT_FILE) | |
.PRECIOUS: %.po |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment