On 16/06/11 23:33, Tsantilas Christos wrote:
Hi all,
I did an incredible discovery this morning: the translate-toolkit
package. This package includes a magic tool called "po2txt", which can
be used to convert the related .po files back to an error-detail.txt file.
I am also attaching a new version of the script. This version avoids
duplicate records from po file.
On 06/16/2011 03:45 AM, Amos Jeffries wrote:
On Wed, 15 Jun 2011 16:24:56 -0600, Alex Rousskov wrote:
On 06/15/2011 03:17 PM, Tsantilas Christos wrote:
From what I can understand a translator will use a program like the
poedit to read the above output and produce a new file for a language.
For example the error-details.txt.el.po file.
I thought the translation blobs produced by your script will go into
existing .po files that are already used for translating error pages and
such. In other words, for any supported language, Squid will have a
single .po file that Squid loads and uses for translations. Am I off
track here? Amos?
That was the idea. Yes.
Yes we can always use one po file. We can just add the output of my
script to existing po files. eg:
# mk-error-details-po.pl error-details.txt >> en.po
or even better using the msgcat utility:
# mk-error-details-po.pl error-details.txt > error-details.po
# msgcat en.po error-details.po
- the English "template" version of error-details.txt needs to go in
errors/error-details.txt,
- scripts/update-pot.sh needs to run your convert right after the
per-page dictionaries for-loop. and before the call to msgcat. You can
see from that for-loop where the resulting .po needs to be.
OK I see. All this thinks need to be integrated to Makefile and
update-pot.sh script
That gets it into the system for people to translate.
As for getting it out again....
I think po2text in error/Makefile.am ".po.lang:" target should produce
the translated version of errors/el/error-details.txt or
errors/error-details.el.txt / .txt.el
We can use the po2txt utility like follows:
po2txt -t error-details.txt -i error-details.po >
errors/en/error-details.txt
or if we merged error-details.po file to the general po files:
po2txt -t error-details.txt -i en.po > errors/en/error-details.txt
Looks OK.
Sweet. Good news. I was a little worried that it would not like the
"label:" line prefixes.
Then the question becomes, how do we allow the admin to edit the
results? an /etc/squid/error-details.txt which loads first and overrides
anything we provide?
It follows the same policy with the error pages templates.
If I am not wrong if the user has configured an error_directory will get
the error details from here else from the related "share/errors/en/"
related path.
Sweet. Nice and easy then.
Minor change on what I said earlier. Add the file to errors/templates/
in bzr. The attached patch should take care of the translate integration.
Amos
--
Please be using
Current Stable Squid 2.7.STABLE9 or 3.1.12
Beta testers wanted for 3.2.0.8 and 3.1.12.2
=== modified file 'configure.ac'
--- configure.ac 2011-05-26 17:06:00 +0000
+++ configure.ac 2011-06-16 13:23:22 +0000
@@ -3323,10 +3323,13 @@
dnl Squid now has .po translation capability, given the right toolkit
if test "x${enable_translation:=yes}" = "xyes" ; then
AX_WITH_PROG([PO2HTML],[po2html])
+ AX_WITH_PROG([PO2TEXT],[po2text])
else
PO2HTML="off"
+ PO2TEXT="off"
fi
AC_SUBST(PO2HTML)
+AC_SUBST(PO2TEXT)
dnl Squid now has limited locale handling ...
dnl on error pages
=== modified file 'errors/Makefile.am'
--- errors/Makefile.am 2011-06-02 10:39:53 +0000
+++ errors/Makefile.am 2011-06-16 13:40:22 +0000
@@ -17,6 +17,7 @@
CLEANFILES = $(TRANSLATE_LANGUAGES) translate-warn
EXTRA_DIST = \
$(ERROR_TEMPLATES) \
+ templates/error-details.txt \
language.list \
template.list \
aliases alias-link.sh alias-upgrade errorpage.css TRANSLATORS COPYRIGHT
@@ -46,10 +47,11 @@
mkdir -p $(top_builddir)/errors/$$lang; \
echo -n "Translate '$$lang' ..."; \
for f in $(ERROR_TEMPLATES); do \
- page=`basename $$f`; \
- $(PO2HTML) $(NOTIDY) --progress=none -i $(top_srcdir)/errors/$$lang.po -t $(top_srcdir)/errors/$$f >$(top_builddir)/errors/$$lang/$$page || exit 1; \
- done; \
- echo "done."; \
+ page=`basename $$f`; \
+ $(PO2HTML) $(NOTIDY) --progress=none -i $(top_srcdir)/errors/$$lang.po -t $(top_srcdir)/errors/$$f >$(top_builddir)/errors/$$lang/$$page || exit 1; \
+ done; \
+ $(PO2TEXT) -t $(top_srcdir)/errors/templates/error-details.txt -i $(top_srcdir)/errors/$$lang.po > $(top_builddir)/errors/$$l/error-details.txt; || exit 1; \
+ echo "done."; \
fi; \
touch $@
@@ -70,7 +72,7 @@
if test -d $(srcdir)/$$l || test -d $(builddir)/$$l; then \
$(mkinstalldirs) $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l; \
fi; \
- for f in $(ERROR_TEMPLATES); do \
+ for f in $(ERROR_TEMPLATES) templates/error-details.txt; do \
page=`basename $$f`; \
if test -f $(builddir)/$$l/$$page; then \
echo "$(INSTALL_DATA) $(builddir)/$$l/$$page $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l"; \
@@ -91,14 +93,14 @@
l=`basename $$l .lang`; \
echo "Located $$l for uninstall ..."; \
if test -d $(srcdir)/$$l; then \
- for f in $(srcdir)/$$l/ERR_*; do \
+ for f in $(srcdir)/$$l/ERR_* $(srcdir)/$$l/error-details.txt; do \
if test -f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; then \
$(RM) $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; \
fi; \
done; \
fi ; \
if test -d $(builddir)/$$l; then \
- for f in $(builddir)/$$l/ERR_*; do \
+ for f in $(builddir)/$$l/ERR_* $(builddir)/$$l/error-details.txt; do \
if test -f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; then \
$(RM) $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; \
fi; \
@@ -119,8 +121,8 @@
lang=`basename $$lang .lang`; \
if test -d $$lang ; then \
mkdir -p $(distdir)/$$lang; \
- cp -p $(top_builddir)/errors/$$lang/ERR_* $(distdir)/$$lang \
- || exit 1; \
+ cp -p $(top_builddir)/errors/$$lang/ERR_* $(distdir)/$$lang || exit 1; \
+ cp -p $(top_builddir)/errors/$$lang/error-details.txt $(distdir)/$$lang || exit 1; \
fi; \
done
=== modified file 'scripts/update-pot.sh'
--- scripts/update-pot.sh 2010-01-12 05:31:55 +0000
+++ scripts/update-pot.sh 2011-06-16 13:57:38 +0000
@@ -17,11 +17,18 @@
# make a temp directory for all our workings...
mkdir pot
-# Generate per-page disctionaries ...
+# Generate per-page dictionaries ...
for f in `ls -1 ./templates/`; do
- if test "${f}" != "generic" ; then
+ case ${f} in
+ error-details.txt)
+ ../scripts/mk-error-details-po.pl ./templates/${f} > ./pot/${f}.pot
+ ;;
+ ERR_*)
html2po -i ./templates/${f} -P --duplicates=merge -o ./pot/${f}.pot
- fi
+ ;;
+ *)
+ echo "SKIP: ${f}"
+ esac
done
# merge and sort the per-page .pot into a single master