diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 51 | ||||
-rw-r--r-- | deps.mk | 17 | ||||
-rw-r--r-- | doc/gobang.en.0.adoc | 5 | ||||
-rwxr-xr-x | mkdeps.sh | 24 | ||||
-rw-r--r-- | po/doc/de.po | 24 | ||||
-rw-r--r-- | po/doc/doc.pot | 23 | ||||
-rw-r--r-- | po/doc/eo.po | 24 | ||||
-rw-r--r-- | po/doc/es.po | 24 | ||||
-rw-r--r-- | po/doc/fr.po | 24 | ||||
-rw-r--r-- | po/doc/note.txt | 5 | ||||
-rw-r--r-- | po/doc/po4a.cfg | 5 | ||||
-rw-r--r-- | po/doc/pt.po | 24 | ||||
-rw-r--r-- | po/gobang/de.po | 12 | ||||
-rw-r--r-- | po/gobang/eo.po | 12 | ||||
-rw-r--r-- | po/gobang/es.po | 12 | ||||
-rw-r--r-- | po/gobang/fr.po | 12 | ||||
-rw-r--r-- | po/gobang/gobang.pot | 12 | ||||
-rw-r--r-- | po/gobang/po4a.cfg | 3 | ||||
-rw-r--r-- | po/gobang/pt.po | 12 | ||||
-rw-r--r-- | src/gobang.go | 3 |
21 files changed, 320 insertions, 13 deletions
@@ -1,4 +1,7 @@ -/src/version.go +/doc/* +!/doc/*.en.*.adoc +/po/*/*.mo +/src/meta.go /*.bin /src/*.a /src/*.bin @@ -3,7 +3,6 @@ DATE = 1970-01-01 VERSION = 0.1.0 NAME = gobang NAME_UC = $(NAME) -LANGUAGES = en ## Installation prefix. Defaults to "/usr". PREFIX = /usr BINDIR = $(PREFIX)/bin @@ -24,16 +23,22 @@ GOLDFLAGS = -L $(GOLIBDIR) .SUFFIXES: -.SUFFIXES: .go .a .bin .bin-check +.SUFFIXES: .go .a .bin .bin-check .adoc .po .mo .go.a: go tool compile -I $(@D) $(GOCFLAGS) -o $@ -p $(*F) \ `find $< $$(if [ $(*F) != main ]; then \ - echo src/$(NAME).go src/version.go; fi) | uniq` + echo src/$(NAME).go src/meta.go; fi) | uniq` .a.bin: go tool link -L $(@D) $(GOLDFLAGS) -o $@ --extldflags '$(LDLIBS)' $< +.adoc: + asciidoctor -b manpage -o $@ $< + +.po.mo: + msgfmt -cfv -o $@ $< + all: @@ -46,17 +51,23 @@ mains.bin = $(mains.go:.go=.bin) functional/lib.a = $(functional/lib.go:.go=.a) fuzz/lib.a = $(fuzz/lib.go:.go=.a) benchmarks/lib.a = $(benchmarks/lib.go:.go=.a) +manpages.N.adoc = $(manpages.en.N.adoc) $(manpages.XX.N.adoc) +manpages.N = $(manpages.N.adoc:.adoc=) +sources.mo = $(sources.po:.po=.mo) sources = \ src/$(NAME).go \ - src/version.go \ + src/meta.go \ derived-assets = \ - src/version.go \ + src/meta.go \ $(libs.a) \ $(mains.a) \ $(mains.bin) \ + $(manpages.XX.N.adoc) \ + $(manpages.N) \ + $(sources.mo) \ side-assets = \ tests/fuzz/corpus/ \ @@ -70,15 +81,21 @@ all: $(derived-assets) $(libs.a): Makefile deps.mk -$(libs.a): src/$(NAME).go src/version.go +$(libs.a): src/$(NAME).go src/meta.go $(fuzz/lib.a): go tool compile $(GOCFLAGS) -o $@ -p $(NAME) -d=libfuzzer \ - $*.go src/$(NAME).go src/version.go + $*.go src/$(NAME).go src/meta.go + +src/meta.go: Makefile + echo 'package $(NAME)' > $@ + echo 'const Version = "$(VERSION)"' >> $@ + echo 'const Name = "$(NAME)"' >> $@ + echo 'const LOCALEDIR = "$(LOCALEDIR)"' >> $@ -src/version.go: Makefile - echo 'package $(NAME); const Version = "$(VERSION)"' > $@ +$(manpages.XX.N.adoc): po/doc/po4a.cfg + po4a --no-update --translate-only $@ po/doc/po4a.cfg @@ -130,6 +147,17 @@ bench: $(benchmarks/main.bin-check) +i18n-doc: + po4a po/doc/po4a.cfg + +i18n-code: + gotext src/$(NAME).go > po/$(NAME)/$(NAME).pot + po4a po/$(NAME)/po4a.cfg + +i18n: i18n-doc i18n-code + + + ## Remove *all* derived artifacts produced during the build. ## A dedicated test asserts that this is always true. clean: @@ -145,6 +173,8 @@ install: all cp src/$(NAME).a '$(DESTDIR)$(GOLIBDIR)' cp $(sources) '$(DESTDIR)$(SRCDIR)' + instool '$(DESTDIR)$(MANDIR)' install man $(manpages.N) + instool '$(DESTDIR)$(LOCALEDIR)' install mo $(sources.mo) ## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror ## of the "install" target, and removes *all* that was installed. @@ -154,6 +184,9 @@ uninstall: '$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \ '$(DESTDIR)$(SRCDIR)' \ + instool '$(DESTDIR)$(MANDIR)' uninstall man $(manpages.N) + instool '$(DESTDIR)$(LOCALEDIR)' uninstall mo $(sources.mo) + ALWAYS: @@ -13,6 +13,23 @@ mains.go = \ tests/fuzz/heredoc/main.go \ tests/main.go \ +manpages.en.N.adoc = \ + doc/gobang.en.0.adoc \ + +manpages.XX.N.adoc = \ + doc/gobang.de.0.adoc \ + doc/gobang.eo.0.adoc \ + doc/gobang.es.0.adoc \ + doc/gobang.fr.0.adoc \ + doc/gobang.pt.0.adoc \ + +sources.po = \ + po/gobang/de.po \ + po/gobang/eo.po \ + po/gobang/es.po \ + po/gobang/fr.po \ + po/gobang/pt.po \ + functional/lib.go = \ tests/functional/metrics/gobang.go \ diff --git a/doc/gobang.en.0.adoc b/doc/gobang.en.0.adoc new file mode 100644 index 0000000..2c9ccce --- /dev/null +++ b/doc/gobang.en.0.adoc @@ -0,0 +1,5 @@ += gobang(0) + +== NAME + +gobang - . @@ -5,16 +5,36 @@ export LANG=POSIX.UTF-8 libs() { - find src tests -name '*.go' | grep -v '/main\.go$' | - grep -v '/version\.go$' + find src tests -name '*.go' | + grep -Ev '/(main|meta)\.go$' | + grep -Ev '/_cgo_(import|gotypes)\.go$' | + grep -Ev '\.cgo1\.go$' } mains() { find src tests -name '*.go' | grep '/main\.go$' } +docs() { + find doc/*.en.*.adoc +} + +xdocs() { + for l in `find po/doc/*.po | xargs -I% basename % .po`; do + docs | sed 's|/\(.*\)\.en\.\(.*\)$|/\1.'"$l"'.\2|' + done +} + +pos() { + find po/ -name '*.po' | grep -Ev '^po/(doc|tests)/' +} + + libs | varlist 'libs.go' mains | varlist 'mains.go' +docs | varlist 'manpages.en.N.adoc' +xdocs | varlist 'manpages.XX.N.adoc' +pos | varlist 'sources.po' find tests/functional/*/*.go -not -name main.go | varlist 'functional/lib.go' find tests/functional/*/main.go | varlist 'functional/main.go' diff --git a/po/doc/de.po b/po/doc/de.po new file mode 100644 index 0000000..740aa82 --- /dev/null +++ b/po/doc/de.po @@ -0,0 +1,24 @@ +msgid "" +msgstr "" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/gobang.en.0.adoc:1 +#, no-wrap +msgid "gobang(0)" +msgstr "" + +#. type: Title == +#: doc/gobang.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/gobang.en.0.adoc:5 +msgid "gobang - ." +msgstr "" diff --git a/po/doc/doc.pot b/po/doc/doc.pot new file mode 100644 index 0000000..58aefcf --- /dev/null +++ b/po/doc/doc.pot @@ -0,0 +1,23 @@ +msgid "" +msgstr "" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. type: Title = +#: doc/gobang.en.0.adoc:1 +#, no-wrap +msgid "gobang(0)" +msgstr "" + +#. type: Title == +#: doc/gobang.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/gobang.en.0.adoc:5 +msgid "gobang - ." +msgstr "" diff --git a/po/doc/eo.po b/po/doc/eo.po new file mode 100644 index 0000000..0bdf787 --- /dev/null +++ b/po/doc/eo.po @@ -0,0 +1,24 @@ +msgid "" +msgstr "" +"Language: eo\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/gobang.en.0.adoc:1 +#, no-wrap +msgid "gobang(0)" +msgstr "" + +#. type: Title == +#: doc/gobang.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/gobang.en.0.adoc:5 +msgid "gobang - ." +msgstr "" diff --git a/po/doc/es.po b/po/doc/es.po new file mode 100644 index 0000000..57d34c5 --- /dev/null +++ b/po/doc/es.po @@ -0,0 +1,24 @@ +msgid "" +msgstr "" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/gobang.en.0.adoc:1 +#, no-wrap +msgid "gobang(0)" +msgstr "" + +#. type: Title == +#: doc/gobang.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/gobang.en.0.adoc:5 +msgid "gobang - ." +msgstr "" diff --git a/po/doc/fr.po b/po/doc/fr.po new file mode 100644 index 0000000..063ae59 --- /dev/null +++ b/po/doc/fr.po @@ -0,0 +1,24 @@ +msgid "" +msgstr "" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. type: Title = +#: doc/gobang.en.0.adoc:1 +#, no-wrap +msgid "gobang(0)" +msgstr "" + +#. type: Title == +#: doc/gobang.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/gobang.en.0.adoc:5 +msgid "gobang - ." +msgstr "" diff --git a/po/doc/note.txt b/po/doc/note.txt new file mode 100644 index 0000000..45279a4 --- /dev/null +++ b/po/doc/note.txt @@ -0,0 +1,5 @@ +PO4A-HEADER: mode=eof + + + +// Generated from po4a(1). diff --git a/po/doc/po4a.cfg b/po/doc/po4a.cfg new file mode 100644 index 0000000..9b9b0c6 --- /dev/null +++ b/po/doc/po4a.cfg @@ -0,0 +1,5 @@ +[options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 --addendum-charset UTF-8 + +[po_directory] po/doc + +[type: asciidoc] doc/gobang.en.0.adoc $lang:doc/gobang.$lang.0.adoc diff --git a/po/doc/pt.po b/po/doc/pt.po new file mode 100644 index 0000000..c0fb19d --- /dev/null +++ b/po/doc/pt.po @@ -0,0 +1,24 @@ +msgid "" +msgstr "" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/gobang.en.0.adoc:1 +#, no-wrap +msgid "gobang(0)" +msgstr "" + +#. type: Title == +#: doc/gobang.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/gobang.en.0.adoc:5 +msgid "gobang - ." +msgstr "" diff --git a/po/gobang/de.po b/po/gobang/de.po new file mode 100644 index 0000000..f1aa2a4 --- /dev/null +++ b/po/gobang/de.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/gobang.go:221 +#, c-format +msgid "error %w on top of %w" +msgstr "" diff --git a/po/gobang/eo.po b/po/gobang/eo.po new file mode 100644 index 0000000..79e89e7 --- /dev/null +++ b/po/gobang/eo.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Language: eo\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/gobang.go:221 +#, c-format +msgid "error %w on top of %w" +msgstr "" diff --git a/po/gobang/es.po b/po/gobang/es.po new file mode 100644 index 0000000..d8c7acf --- /dev/null +++ b/po/gobang/es.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/gobang.go:221 +#, c-format +msgid "error %w on top of %w" +msgstr "" diff --git a/po/gobang/fr.po b/po/gobang/fr.po new file mode 100644 index 0000000..cc11c38 --- /dev/null +++ b/po/gobang/fr.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: src/gobang.go:221 +#, c-format +msgid "error %w on top of %w" +msgstr "" diff --git a/po/gobang/gobang.pot b/po/gobang/gobang.pot new file mode 100644 index 0000000..77f5d65 --- /dev/null +++ b/po/gobang/gobang.pot @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/gobang.go:221 +#, c-format +msgid "error %w on top of %w" +msgstr "" + diff --git a/po/gobang/po4a.cfg b/po/gobang/po4a.cfg new file mode 100644 index 0000000..af92025 --- /dev/null +++ b/po/gobang/po4a.cfg @@ -0,0 +1,3 @@ +[options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 --addendum-charset UTF-8 + +[po_directory] po/gobang diff --git a/po/gobang/pt.po b/po/gobang/pt.po new file mode 100644 index 0000000..ef6e64c --- /dev/null +++ b/po/gobang/pt.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/gobang.go:221 +#, c-format +msgid "error %w on top of %w" +msgstr "" diff --git a/src/gobang.go b/src/gobang.go index 88b4c57..e7280a9 100644 --- a/src/gobang.go +++ b/src/gobang.go @@ -17,6 +17,7 @@ import ( "strings" "time" + gt "gotext" "uuid" ) @@ -217,7 +218,7 @@ func WrapErrors(errs ...error) error { out = err } else { out = fmt.Errorf( - "error %w on top of %w", + gt.Gettext("error %w on top of %w"), err, out, ) |