public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
From: "Mike M. Volokhov" <mishka@apk.od.ua>
To: help-gnats@gnu.org
Subject: Gnats{web} localization
Date: Wed, 29 Sep 2004 18:10:00 -0000	[thread overview]
Message-ID: <20040929141447.6207c085.mishka@apk.od.ua> (raw)

[-- Attachment #1: Type: text/plain, Size: 2747 bytes --]

Greetings!

I've looked to problem tracking tool and choose the Gnats due to it
lightweight, modular, and robust backend. I'm newbie to Gnats
installation and administration. So when I've tried to deploy the PR
database (Gnats 4.0) on my corporate support site, I'm faced with l12n
and i18n problems. Gnats and Gnatsweb seems doesn't support non-english
messages at all, but my users are speaking Russian.


First, I need at least correct handling of non-ASCII characters.

Fortunately, Gnats tools uses is*() ctype functions and was linked
against libintl library (I'm use NetBSD), thus it correctly operates on
any 8-bit characters (16-bit ones should processed as two 8-bit chars).
But one problem still pursuit me - the e-mail notifications:

	1) Subject fileld must be MIME encoded.
	2) Message must contain charset specification.

So as my time was limited, I've just changed header{} at mail-format{}
section as follows:

	header {
	  format "Content-Type: text/plain; charset=koi8-r\nSubject: Re: %s/%s\n"
	  fields { "Category" "Number" } 
	}

I.e. Subject now doesn't contains synopsis text, and message have a
Content-Type field. 

Next, briefly looking over the code and documentation of gnatsweb.pl,
I'm found it was not really designed for non-english sites. Thus, two
new variables should fix this problem for me:

	site_html_language	- the language for returned web pages
	site_html_charset	- the charset for Content-Type

Depending on that variables (which had set values to "en-US" and
"ISO-8859-1" respectively) Gnatsweb now adds all corresponded headers
where needed. These variables are overridable from gnatsweb-site.pl.
Please see a patch provided in attachment.


Second, I need complete localization for Gnats. I.e. all messages, field
names, categories and so on should be easy changed by site's own values
on any preferred language. I'm personally have two ideas for this:

1) Add yet another field to Gnats PR structure: ">Encoding:". The Gnats
will use UTF-8, for example, as internal charset encoding. An encoding
for any newly arrived PR will be easy determined by this field and
autoconverted to UTF-8 using iconv library. User tools shoud specify
encoding when talking to gnatsd or when fetching PR in any way. The
directive "gnats-encoding" should be affected to all Gnats internal
data described below (field names, ...)

2) Use XML as internal format for database processing. This allows use
power and simplicity of XML i18n.

Indifferently to solution choosed, user tools must be adopted to this
behaviour (supplying and querying encoding values and so on).

Now I have a time to work on any of those (or any other) solution in way
to Gnats localization.


Any comments would be appreciated.

--
TIA, Mishka.


[-- Attachment #2: gnatsweb.pl.patch --]
[-- Type: text/plain, Size: 2587 bytes --]

--- gnatsweb.pl.orig	Tue Sep 21 09:28:34 2004
+++ gnatsweb.pl	Wed Sep 29 12:32:01 2004
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/pkg/bin/perl -w
 #
 # Gnatsweb - web front-end to GNATS
 #
@@ -39,6 +39,8 @@
 $global_cookie_expires $global_cookie_path $textwidth
 $site_allow_remote_debug $attachment_delimiter %mark_urls
 $gnats_info_top %site_pr_submission_address $VERSION);
+# Addon for Gnatsweb localization, overridable from gnatsweb-site.pl too
+use vars qw($site_html_language $site_html_charset);
 
 # dynamic configuration switches, set during initial gnatsd
 # communication and general setup
@@ -93,6 +95,10 @@
 #     released, you won't need to edit them again.
 #
 
+# Internationalization.
+$site_html_language = 'en-US';
+$site_html_charset = 'ISO-8859-1';
+
 # Info about your gnats host.
 $site_gnats_host = 'localhost';
 $site_gnats_port = 1529;
@@ -984,7 +990,7 @@
   # in the expected way. It needs a content-disposition of "file".
   ($ENV{'HTTP_USER_AGENT'} =~ "MSIE 5.5") ? ($disp = 'file') : ($disp = 'attachment');
   # Now serve the attachment, with the appropriate headers.
-  print_header(-type => 'application/octet-stream',
+  print_generic_header(-type => 'application/octet-stream',
                -content_disposition => "$disp; filename=\"$$hash_ref{'filename'}\"");
   print $$hash_ref{'data'};
 }
@@ -3002,10 +3008,10 @@
   $val;
 }
 
-# print_header -
+# print_generic_header -
 #     Print HTTP header unless it's been printed already.
 #
-sub print_header
+sub print_generic_header
 {
   # Protect against multiple calls.
   return if $print_header_done;
@@ -3014,6 +3020,17 @@
   print $q->header(@_);
 }
 
+# print_header -
+#     Print HTTP header for HTML pages
+sub print_header
+{
+  my @header_opts = @_;
+  push(@header_opts, -charset => $site_html_charset)
+	if (defined $site_html_charset);
+
+  print_generic_header(@header_opts);
+}
+
 # page_start_html -
 #
 #     Print the HTML which starts off each page (<html><head>...</head>).  
@@ -3049,6 +3066,11 @@
 
   # Call start_html, with -bgcolor if we need to override that.
   my @args = (-title=>"$title - $site_banner_text");
+  push(@args, -head=>$q->meta({-http_equiv=>'Content-Type',
+  	      -content=>"text/html; charset=$site_html_charset"}))
+	if defined($site_html_charset);
+  push(@args, -lang=>$site_html_language)
+        if defined($site_html_language);
   push(@args, -bgcolor=>$site_background)
         if defined($site_background);
   push(@args, -style=>{-src=>$site_stylesheet})

[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnats

             reply	other threads:[~2004-09-29 11:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-29 18:10 Mike M. Volokhov [this message]
2004-09-30  8:34 ` Chad Walstrom
2004-09-30 16:57   ` Mike M. Volokhov

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=20040929141447.6207c085.mishka@apk.od.ua \
    --to=mishka@apk.od.ua \
    --cc=help-gnats@gnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).