From fbd331dd073dc7052197b5c4263a6c6000e5b623 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Wed, 21 Aug 2019 22:18:14 +0200 Subject: [PATCH] [i18n] Switch `make pot` to xgettext (#5237) This introduces context to our strings to differentiate them when necessary. The syntax chosen is `C_()`, following [glib](https://developer.gnome.org/glib/2.28/glib-I18N.html#C-:CAPS). ```lua local _ = require("gettext") local C_ = _.pgettext C_("Menu|StyleTweaks|", "Pages") ``` Closes #5232. --- Makefile | 8 ++++---- frontend/ui/data/css_tweaks.lua | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a7db2a42d..7ddffaae9 100644 --- a/Makefile +++ b/Makefile @@ -462,15 +462,15 @@ pocketbook-toolchain: # for gettext DOMAIN=koreader TEMPLATE_DIR=l10n/templates -KOREADER_MISC_TOOL=../koreader-misc -XGETTEXT_BIN=$(KOREADER_MISC_TOOL)/gettext/lua_xgettext.py +XGETTEXT_BIN=xgettext pot: mkdir -p $(TEMPLATE_DIR) - $(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \ + $(XGETTEXT_BIN) --from-code=utf-8 --keyword=C_:1c,2 \ + reader.lua `find frontend -iname "*.lua"` \ `find plugins -iname "*.lua"` \ `find tools -iname "*.lua"` \ - > $(TEMPLATE_DIR)/$(DOMAIN).pot + -o $(TEMPLATE_DIR)/$(DOMAIN).pot # push source file to Transifex $(MAKE) -i -C l10n bootstrap $(MAKE) -C l10n push diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 538d235fa..70ce3e92b 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -10,10 +10,11 @@ They may have the following optional attributes: ]] local _ = require("gettext") +local C_ = _.pgettext local CssTweaks = { { - title = _("Pages"), + title = C_("Style tweaks category", "Pages"), { id = "margin_body_0"; title = _("Ignore publisher page margins"),