gettext: switch to binary catalogs

Binary catalogs are more space efficient (total translations disk usage:
14MB instead of 35MB), and easier and faster (roughly 10 times) to load:
no parsing, and less processing (no need to unescape strings).

Not much difference on the Android APK size (a ~600KB reduction), but
other TAR.GZ / ZIP distributions see a reduction of ~3.5MB.
This commit is contained in:
Benoit Pierre
2025-06-19 23:37:59 +02:00
committed by Frans de Jonge
parent b2f9530788
commit 456ce2fa36
4 changed files with 263 additions and 196 deletions

View File

@@ -1,4 +1,4 @@
PHONY = all android-ndk android-sdk base clean distclean doc fetchthirdparty po pot re static-check
PHONY = all android-ndk android-sdk base clean distclean doc fetchthirdparty re static-check
SOUND = $(INSTALL_DIR)/%
# koreader-base directory
@@ -81,6 +81,7 @@ ev_replay.py
help
history
l10n/templates
l10n/*/*.po
ota
resources/fonts*
resources/icons/src*
@@ -134,7 +135,7 @@ $(foreach a,$1,'$(if $(filter --%,$a),$a,$(abspath $a))') $(or $2,koreader)
$(call release_excludes,$(or $2,koreader)/)
endef
all: base
all: base mo
install -d $(INSTALL_DIR)/koreader
rm -f $(INSTALL_DIR)/koreader/git-rev; echo "$(VERSION)" > $(INSTALL_DIR)/koreader/git-rev
ifdef ANDROID
@@ -190,7 +191,7 @@ else
git submodule update --jobs 3 --init --recursive
endif
clean: base-clean
clean: base-clean mo-clean
rm -rf $(INSTALL_DIR)
distclean: clean base-distclean
@@ -209,31 +210,14 @@ ifneq (,$(wildcard make/$(TARGET).mk))
include make/$(TARGET).mk
endif
include make/gettext.mk
android-ndk:
$(MAKE) -C $(KOR_BASE)/toolchain $(ANDROID_NDK_HOME)
android-sdk:
$(MAKE) -C $(KOR_BASE)/toolchain $(ANDROID_HOME)
# for gettext
DOMAIN=koreader
TEMPLATE_DIR=l10n/templates
XGETTEXT_BIN=xgettext
pot: po
mkdir -p $(TEMPLATE_DIR)
$(XGETTEXT_BIN) --from-code=utf-8 \
--keyword=C_:1c,2 --keyword=N_:1,2 --keyword=NC_:1c,2,3 \
--add-comments=@translators \
reader.lua `find frontend -iname "*.lua" | sort` \
`find plugins -iname "*.lua" | sort` \
`find tools -iname "*.lua" | sort` \
-o $(TEMPLATE_DIR)/$(DOMAIN).pot
po:
git submodule update --remote l10n
static-check:
@if which luacheck > /dev/null; then \
luacheck -q {reader,setupkoenv,datastorage}.lua frontend plugins spec; \