I did some modification of GnuCash website.

Tao Wang dancefire at gmail.com
Wed May 19 13:26:26 EDT 2010


Hi,

I'm sorry about forgeting answer the question last time. I was just
focused on the fixing the problem.

When I reach the website codes, I just feel the site structure doesn't
look in a nice way. There are better ways to do the multilanguage than
making a set of soft link/copy for each language. That is the reason
why I start tried to optimize the code.

I was not realized the multilanguage support for mail list site will
stop working by my modifications. I thought they were different code
base. But, don't be worry, I believe the patches I provided will fix
the problem and get it to normal. And, actually, my previous patch
already works, I found the cookies for 'lists.gnucash.org' has been
set already, it already passed the correct LANG to namazu. The reason
why it shows English only is that the makefile didn't work since the
structure changed. I fixed the problem, so just apply the patch and
'make nmz'.

For utf-8, after I received replies about the mailing list problem, I
realized that the multi-language support for mail lists searching
never worked for me. I always saw the chaos header, which should be
Chinese/Japanese characters. And I remembered that I didn't see
Chinese translation for menu or namazu works ever on
'lists.gnucash.org', when I click 'zh_CN', it only shows the English
interface, maybe because missing locale or forget regenerate the
template. My previous modification of using php-gettext instead of
default gettext will fix the former.

After I go through the code, that the header chaos string problem is
caused by encoding problem, unless it encoded by "utf-8", it will show

"日本語 | Nederlands | Norsk Bokmål | Português | 中文"
 as
" 日本語 | Nederlands | Norsk Bokmål | Português | 中文  "

And for the menu translated by CJK, definitely will become chaos if
the encoding is not 'utf-8', so, even my patch works to be able
generating correct templates for zh_CN, it will only shows chaos for
the CJK strings.

I splitted my previous patch to 6 parts, which should make each parts
more clear target.

[gnucash-htdocs_search_fix2_part0_fix_search_templates]

This is the urgent patch, which will fix the makefile and links
problems, so after this patch applied and regenerated templates, the
site will works for multi-languages support.

[gnucash-htdocs_search_fix2_part1_gettext_update]

This patch update php-gettext to 1.0.10, which fixed a bug in 1.0.9. I
recommand to apply the patch, however, the site will works without the
patch, just some errors will be logged into apache's error.log

[gnucash-htdocs_search_fix2_part2_misc]

This is a trivial patch, update copyright info and remove $mimeline.

[gnucash-htdocs_search_fix2_part3_convert_po_to_utf8]

This patch will convert 'po files' of es, en_GB, pl, nb to utf-8. I
found some encoding error when running 'make nmz' for 'pl', after
troubleshooting, I found that pl.po was stated encode in 'iso-8859-1'
or 'iso-8859-15', however, it's not. I found it's more likely encoded
in 'iso-8859-2'. So, I just to ensure all po files in utf-8, which
make translator in other language or environment easier. And because
de.po is utf8 already, and works in namazu before, it has good reason
that all these conversion will not affect the namazu result.

[gnucash-htdocs_search_fix2_part4_merge_ja_to_po]

I merged the strings in existing templates to ja.po. So, it's possible
to remove 'ja' template and treat it as same way as other languages.
Anyway, it's safe to apply the patch, because unless the templates for
'ja' removed, the po file will not be used for namazu template.

[gnucash-htdocs_search_fix2_part5_remove_ja_templates]

This patch remove the templates for 'ja', and modified the Makefile to
generate the 'ja' templates from *.php_html and 'ja.po'.
We don't have gnucash-ja mail list, so there is no contents of mail
list archive will be encoded in 'EUC_JP' or 'Shift_JIS". Only the
interface will be shown in Japanese. So, we do not need seperate
templates for 'ja', if we do, then we need seperate templates for
Chinese too. But, I don't think it's necessary, most CJK people will
search gnucash list in English, so we should not worry about encoding
in utf-8 for those languages.


About the namazu encoding problem, I understand the mail archive for
language other than English is not encoded in utf-8, and turn namazu
to utf-8 entirely is not a good solution. However, namazu support to
use different encoding for different languages. We can set
'iso-8859-1' to the German, Franch, etc. and set utf-8 for the rest. I
think user in other languages will never care the "日本語 | 中文" is chaos.
 So, it will makes all of us happy.

To do this, we need modify 2 place:
1) Add following lines to '/etc/namazu/namazurc':

==========================
ContentType     "text/html"

Charset "en"	"utf-8"
Charset "de"	"ISO-8859-1"
Charset "es"	"ISO-8859-1"
Charset "fr"	"ISO-8859-1"
Charset "it"	"ISO-8859-1"
Charset "ja"	"utf-8"
Charset "nl"	"utf-8"
Charset "nb"	"utf-8"
Charset "pl"	"utf-8"
Charset "pt"	"utf-8"
Charset "zh"	"utf-8"
==========================
The first line let namazu control "ContentType" line, and the
following lines specified the charset for each language.

2) Update Makefile to convert encoding for templates of {de es fr it}
from utf-8 to iso-8859-1. Otherwise the non-ascii characters will not
shown correctly.
####################### CUT BEGIN #######################
Index: Makefile
===================================================================
--- Makefile	(revision 19180)
+++ Makefile	(working copy)
@@ -48,10 +50,20 @@
 	  $(MAKE) nmz.onefile FILE="$$f"; \
 	done

+nmz.locale:
+	# convert to ISO_8859-1
+	for f in $(TMPLBASE)*.$(LOCALE); do \
+	  iconv -f utf-8 -t ISO_8859-1//TRANSLIT -o $$f.local -c $$f ; \
+	  mv $$f.local $$f ; \
+	done
+
 nmz:
 	$(MAKE) nmz.lang
 	# other NMZ langs not merged into po system: ja
 	# note: PL is only "mostly" translated.  it diff's differently
 	for l in en ${languages} ; do \
 	  $(MAKE) nmz.lang FILETAIL=.$$l ; \
 	done
+	for l in de es fr it ; do \
+	  $(MAKE) nmz.locale LOCALE=$$l; \
+	done
+
####################### CUT END #######################

I'm sorry for the long reply and my English, but I hope it's clear.

-- 
Regards

Tao Wang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnucash-htdocs_search_fix2_parts.zip
Type: application/zip
Size: 25160 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20100520/28b50dff/attachment.zip>


More information about the gnucash-devel mailing list