Skip to content

Commit

Permalink
feat(rules): Add machine translation targets using DeepL
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jun 21, 2023
1 parent 9d8cdd4 commit 485f3fc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -19,7 +19,7 @@ pkgdata_SCRIPTS = make-shell.zsh
dist_doc_DATA = README.md CHANGELOG.md
dist_license_DATA = LICENSE
nobase_data_DATA = rules/casile.mk $(reverse_lang_key_files)
nobase_dist_data_DATA = rules/rules.mk rules/functions.mk rules/utilities.mk $(lang_key_files)
nobase_dist_data_DATA = rules/rules.mk rules/functions.mk rules/translation.mk rules/utilities.mk $(lang_key_files)
nobase_dist_data_DATA += rules/ebooks.mk rules/mdbook.mk rules/renderings.mk rules/zola.mk
_casile_libs = src/lib.rs src/cli.rs src/config.rs src/i18n.rs
_casile_modules = src/make/mod.rs src/setup/mod.rs src/status/mod.rs
Expand Down
7 changes: 4 additions & 3 deletions configure.ac
Expand Up @@ -93,9 +93,10 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
AC_PROG_EGREP
AC_PROG_MKDIR_P
AX_PROGVAR([bc])
AX_PROGVAR([diff])
AX_PROGVAR([cut])
AX_PROGVAR([curl])
AX_PROGVAR([cut])
AX_PROGVAR([deepl])
AX_PROGVAR([diff])
AX_PROGVAR([entr])
AX_PROGVAR([epubcheck])
AX_PROGVAR([fcconflist], [fc-conflist])
Expand All @@ -119,9 +120,9 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
AX_PROGVAR([pdfjam])
AX_PROGVAR([pdftk])
AX_PROGVAR([pgrep])
AX_PROGVAR([pwait])
AX_PROGVAR([podofobox])
AX_PROGVAR([povray])
AX_PROGVAR([pwait])
AX_PROGVAR([sassc])
AX_PROGVAR([sile])
AX_PROGVAR([sort])
Expand Down
2 changes: 1 addition & 1 deletion hooks/build
Expand Up @@ -11,7 +11,7 @@ RUNTIME_DEPS='bc bcprov curl entr epubcheck fontconfig ghostscript git git-warp-
' tex-gyre-fonts texlive-binextra texlive-core ttf-hack yq zint zola zsh'\
' lua luarocks lua-colors-git lua-filesystem lua-yaml'\
' perl perl-yaml perl-yaml-merge-simple'\
' python python-isbnlib python-pandocfilters python-pantable python-ruamel-yaml python-usfm2osis-cw-git'\
' python python-isbnlib python-deepl python-pandocfilters python-pantable python-ruamel-yaml python-usfm2osis-cw-git'\
' xcftools xorg-server-xvfb'
BUILD_DEPS='base-devel autoconf-archive cargo node-prune yarn'

Expand Down
1 change: 1 addition & 0 deletions rules/casile.mk.in
Expand Up @@ -45,6 +45,7 @@ DIFF ?= @DIFF@
CMP ?= @CMP@
CURL ?= @CURL@
CUT ?= @CUT@
DEEPL ?= @DEEPL@
EGREP ?= @EGREP@
ENTR ?= @ENTR@
EPUBCHECK ?= @EPUBCHECK@
Expand Down
1 change: 1 addition & 0 deletions rules/rules.mk
Expand Up @@ -252,6 +252,7 @@ DISTFILES ?=
DISTDIRS ?=
DISTDIR ?= $(PROJECT)-$(call versioninfo,$(PROJECT))

include $(CASILEDIR)/rules/translation.mk
include $(CASILEDIR)/rules/utilities.mk

.PHONY: all
Expand Down
14 changes: 14 additions & 0 deletions rules/translation.mk
@@ -0,0 +1,14 @@
deepl/%.md: $(BUILDDIR)/deepl/%.docx
mkdir -p $(@D)
$(PANDOC) \
$(PANDOCARGS) \
$(PANDOCFILTERS) \
$^ -o $@

targetlang = $(notdir $(abspath $(dir $1)))
deepldeps = $(call pattern_list,$(shell $(_ENV) list_related_files.zsh srcid $(basename $(notdir $1))),.docx -manifest.yml)

$(BUILDDIR)/deepl/%.docx: $$(call deepldeps,$$@)
$(YQ) -r '.lang' $(filter %-manifest.yml,$^) | read srclang
$(DEEPL) document --from "$${srclang}" --to "$(call targetlang,$@)" $< $(@D)
mv $(@D)/$< $@ ||:

0 comments on commit 485f3fc

Please sign in to comment.