From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-i18n 2/2] make: add proxmox-datacenter-manager translations
Date: Wed, 22 Jan 2025 13:20:34 +0100 [thread overview]
Message-ID: <20250122122034.247847-2-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250122122034.247847-1-m.sandoval@proxmox.com>
The catalog-{lang}.mo files are generated only with strings that are
relevant to the proxmox-datacenter-manager instead of the whole
{lang}.po file. The msgmerge command will produce all strings containing
in the {lang}.po file but the ones that do not concern
proxmox-datacenter-manager.pot will be written without a source file,
then msgattrib will discard all those strings with --no-obsolete. We
throw a --no-fuzzy to further decrease the resulting catalog-{lang}.mo's
file size.
One thing to note is that xtr, unlike our script to extract translations
will add comments, context, and plural forms.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
At the moment this won't compile without changes to proxmox-yew-widget-toolkit
since the msgid "Warning" is both used for a plural and singular string. Adding
a context to the plural variant fixes this:
```diff
modified src/apt_repositories.rs
@@ -873,7 +873,8 @@ fn render_text_with_warnings(text: &str, warnings: &[String]) -> Html {
<i class="fa fa-fw fa-exclamation-circle"/>
</span>
};
- let title = tr!("Warning" | "Warnings" % warnings.len());
+ let title =
+ tr!("This is a string with plural form" => "Warning" | "Warnings" % warnings.len());
let mut tip = Container::new().with_child(html! {<h4>{title}</h4>});
for message in warnings {
tip.add_child(html! {<p>{message}</p>});
```
There is already a patch in the yew-devel with this patch.
Additionally, it might make sense to revisit using xgettext instead of the perl
script for the rest of translations.
.gitmodules | 9 +++++++++
Makefile | 33 ++++++++++++++++++++++++++++++---
debian/control | 6 ++++++
debian/pdm-i18n.install | 1 +
proxmox-datacenter-manager | 1 +
proxmox-yew-comp | 1 +
proxmox-yew-widget-toolkit | 1 +
7 files changed, 49 insertions(+), 3 deletions(-)
create mode 100644 debian/pdm-i18n.install
create mode 160000 proxmox-datacenter-manager
create mode 160000 proxmox-yew-comp
create mode 160000 proxmox-yew-widget-toolkit
diff --git a/.gitmodules b/.gitmodules
index a81a7e3..885b6e1 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -12,3 +12,12 @@
[submodule "proxmox-backup"]
path = proxmox-backup
url = ../proxmox-backup
+[submodule "proxmox-datacenter-manager"]
+ path = proxmox-datacenter-manager
+ url = ../proxmox-datacenter-manager
+[submodule "proxmox-yew-widget-toolkit"]
+ path = proxmox-yew-widget-toolkit
+ url = ../proxmox-yew-widget-toolkit
+[submodule "proxmox-yew-comp"]
+ path = proxmox-yew-comp
+ url = ../proxmox-yew-comp
diff --git a/Makefile b/Makefile
index 90a7453..ca98ef9 100644
--- a/Makefile
+++ b/Makefile
@@ -37,16 +37,19 @@ DSC=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
PVE_I18N_DEB=pve-i18n_$(DEB_VERSION)_all.deb
PMG_I18N_DEB=pmg-i18n_$(DEB_VERSION)_all.deb
PBS_I18N_DEB=pbs-i18n_$(DEB_VERSION)_all.deb
+PDM_I18N_DEB=pdm-i18n_$(DEB_VERSION)_all.deb
-DEBS=$(PMG_I18N_DEB) $(PVE_I18N_DEB) $(PBS_I18N_DEB)
+DEBS=$(PMG_I18N_DEB) $(PVE_I18N_DEB) $(PBS_I18N_DEB) $(PDM_I18N_DEB)
PMGLOCALEDIR=$(DESTDIR)/usr/share/pmg-i18n
PVELOCALEDIR=$(DESTDIR)/usr/share/pve-i18n
PBSLOCALEDIR=$(DESTDIR)/usr/share/pbs-i18n
+PDMLOCALEDIR=$(DESTDIR)/usr/share/pdm-i18n
PMG_LANG_FILES=$(patsubst %, pmg-lang-%.js, $(LINGUAS))
PVE_LANG_FILES=$(patsubst %, pve-lang-%.js, $(LINGUAS))
PBS_LANG_FILES=$(patsubst %, pbs-lang-%.js, $(LINGUAS))
+PDM_LANG_FILES=$(patsubst %, catalog-%.mo, $(LINGUAS))
all:
@@ -78,13 +81,16 @@ submodule:
|| git submodule update --init
.PHONY: install
-install: $(PMG_LANG_FILES) $(PVE_LANG_FILES) $(PBS_LANG_FILES)
+install: $(PMG_LANG_FILES) $(PVE_LANG_FILES) $(PBS_LANG_FILES) $(PDM_LANG_FILES)
install -d $(PMGLOCALEDIR)
install -m 0644 $(PMG_LANG_FILES) $(PMGLOCALEDIR)
install -d $(PVELOCALEDIR)
install -m 0644 $(PVE_LANG_FILES) $(PVELOCALEDIR)
install -d $(PBSLOCALEDIR)
install -m 0644 $(PBS_LANG_FILES) $(PBSLOCALEDIR)
+ install -d $(PDMLOCALEDIR)
+ install -m 0644 $(PDM_LANG_FILES) $(PDMLOCALEDIR)
+
# compat symlinks for kr -> ko correction.
ln -s pmg-lang-ko.js $(PMGLOCALEDIR)/pmg-lang-kr.js
ln -s pve-lang-ko.js $(PVELOCALEDIR)/pve-lang-kr.js
@@ -99,18 +105,35 @@ pve-lang-%.js: %.po
pbs-lang-%.js: %.po
./po2js.pl -t pbs -v "$(DEB_VERSION)" -o pbs-lang-$*.js $?
+catalog-%.mo: %.po proxmox-datacenter-manager.pot
+ msgmerge $< proxmox-datacenter-manager.pot | msgattrib --no-fuzzy --no-obsolete | msgfmt --verbose --output-file $@ $<;
+
# parameter 1 is the name
# parameter 2 is the directory
define potupdate
./jsgettext.pl -p "$(1) $(shell cd $(2);git rev-parse HEAD)" -o $(1).pot $(2)
endef
+# parameter 1 is the name
+# parameter 2 is the directory
+define xtrpotupdate
+ xtr --package-name "$(1)" \
+ --package-version="$(shell cd $(2);git rev-parse HEAD)" \
+ --msgid-bugs-address="<support@proxmox.com>" \
+ --copyright-holder="Copyright (C) Proxmox Server Solutions GmbH <support@proxmox.com> & the translation contributors." \
+ --output $(1).pot \
+ $(2)*.rs
+endef
+
.PHONY: update update_pot do_update
update_pot: submodule
$(call potupdate,proxmox-widget-toolkit,proxmox-widget-toolkit/)
$(call potupdate,pve-manager,pve-manager/www/manager6/)
$(call potupdate,proxmox-mailgateway,pmg-gui/js/)
$(call potupdate,proxmox-backup,proxmox-backup/www/)
+ $(call xtrpotupdate,proxmox-datacenter-manager-ui,proxmox-datacenter-manager/ui/src/)
+ $(call xtrpotupdate,proxmox-yew-comp,proxmox-yew-comp/src/)
+ $(call xtrpotupdate,proxmox-yew-widget-toolkit,proxmox-yew-widget-toolkit/src/)
do_update:
$(MAKE) update_pot
@@ -128,7 +151,11 @@ init-%.po: messages.pot
msginit -i $^ -l $^ -o $*.po --no-translator
.INTERMEDIATE: messages.pot
-messages.pot: proxmox-widget-toolkit.pot proxmox-mailgateway.pot pve-manager.pot proxmox-backup.pot
+messages.pot: proxmox-widget-toolkit.pot proxmox-mailgateway.pot pve-manager.pot proxmox-backup.pot proxmox-datacenter-manager-ui.pot proxmox-yew-comp.pot proxmox-yew-widget-toolkit.pot
+ xgettext $^ --msgid-bugs-address="<support@proxmox.com>" --output $@
+
+.INTERMEDIATE: proxmox-datacenter-manager.pot
+proxmox-datacenter-manager.pot: proxmox-datacenter-manager-ui.pot proxmox-yew-comp.pot proxmox-yew-widget-toolkit.pot
xgettext $^ --msgid-bugs-address="<support@proxmox.com>" --output $@
.PHONY: distclean
diff --git a/debian/control b/debian/control
index 4fa8cfb..e27b3b6 100644
--- a/debian/control
+++ b/debian/control
@@ -23,3 +23,9 @@ Architecture: all
Depends: ${misc:Depends},
Description: Internationalization support for Proxmox VE
This package provides the translations into all available languages.
+
+Package: pdm-i18n
+Architecture: all
+Depends: ${misc:Depends},
+Description: Internationalization support for Proxmox Datacenter Manager
+ This package provides the translations into all available languages.
diff --git a/debian/pdm-i18n.install b/debian/pdm-i18n.install
new file mode 100644
index 0000000..628332b
--- /dev/null
+++ b/debian/pdm-i18n.install
@@ -0,0 +1 @@
+/usr/share/pdm-i18n/
diff --git a/proxmox-datacenter-manager b/proxmox-datacenter-manager
new file mode 160000
index 0000000..2009982
--- /dev/null
+++ b/proxmox-datacenter-manager
@@ -0,0 +1 @@
+Subproject commit 2009982928cde8d4e0e3de26fd4bf15d1b1feab3
diff --git a/proxmox-yew-comp b/proxmox-yew-comp
new file mode 160000
index 0000000..66b80c2
--- /dev/null
+++ b/proxmox-yew-comp
@@ -0,0 +1 @@
+Subproject commit 66b80c208add1004b97c6af716696985db861e67
diff --git a/proxmox-yew-widget-toolkit b/proxmox-yew-widget-toolkit
new file mode 160000
index 0000000..72e721c
--- /dev/null
+++ b/proxmox-yew-widget-toolkit
@@ -0,0 +1 @@
+Subproject commit 72e721c070676c08ef731a62a3b14c6d046ca540
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-01-22 12:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 12:20 [pve-devel] [PATCH proxmox-i18n 1/2] makefile: prefer using xgettext over msgcat Maximiliano Sandoval
2025-01-22 12:20 ` Maximiliano Sandoval [this message]
2025-01-22 12:22 ` [pve-devel] [PATCH proxmox-i18n 2/2] make: add proxmox-datacenter-manager translations Maximiliano Sandoval
2025-01-22 13:05 ` Thomas Lamprecht
2025-01-22 13:15 ` Maximiliano Sandoval
2025-01-24 14:37 ` Maximiliano Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250122122034.247847-2-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.