Sa
mba-JP Top Page [ News | Documentation | Project | Event | Users Group | Mailing List ]
JAPANESEENGLISH

Release note for SWAT message i18n

Oct, 6, 2000
Ryo Kawahara
rkawa@lbe.co.jp
https://www.samba.gr.jp/project/samba-ja/

Table of contents

Technical Notes

Detail information of internationalized SWAT (Samba Web Administration Tool)

modification for the i18n of SWAT is written in this section.

How Content Negotiation works.

This feature is an implementation of "Content Negotiation". There is a ACCEPT-LANGUAGE header in HTTP/1.1 protocol. A web browser sends this header in order to tell the server which language of the data is acceptable. The server reads this header and decides the type of the data to return.

See rfc2616 which defines HTTP/1.1 Content Negotiation for more information

HTML file selection functionality

In this version, SWAT now can recieve this header and returns the data file in the directory of the requested language. For example, when you clicked "smb.conf.5.html" link and the language of the browser (Accept-Language header)is set as: "ja, es" (without quotes) then, SWAT searches the data file with following order:

  1. $SWATDIR/swat/ja/help/smb.conf.5.html : corresponds to the lang ja
  2. $SWATDIR/swat/es/help/smb.conf.5.html : corresponds to the lang es
  3. $SWATDIR/swat/help/smb.conf.5.html : default file

$SWATDIR represent SWAT installation directory (such as /usr/local/samba/swat). If no data is found in ja, es directories, then original data file is used. So you can translate only a part of the documentation and leave the rest untranslated. SWAT is able to use in such a circumstance.

Note about the priority of languages

In this version of SWAT, priority option q= used in Accept-Language header is ignored and the priority is determined by the order of the languages. In addition to that, "*" expression which represents any language is also not supported.

modified files
source/web/neg_lang.c -
source/web/cgi.c -

Message Catalog functionality

i18n of output message with gettext library

Output messages in SWAT source code is now able to be changed according to the runtime setting of the $LANGUAGE environment variable. The message data are in message catalog files and gettext library functions refer to these files. Messages whose language is changed are marked like _("hoge"). (It is a macro and actually substituted with gettext())

In order to change language from web browser, SWAT sets the $LANGUAGE variable to the language which web browser requested.

modified files
source/po/*.po message catalogs
source/web/swat.c -
source/web/statuspage.c -
source/param/loadparm.c -

Support for web browsers that do not support HTTP/1.1

We have checked that IE3,4,5, NN4.x, lynx and w3m can send Accept-Language header, but web browsers that don't send the header might exist. Please use --with-swat-def-lang=LANG configure option to specify the default language for them. by default, SWAT does not use this value. Only one language name (like ja) can be specified.

fixed bug in writing from SWAT with multibyte characters.

In samba-2.0.6 and later, smb.conf file must be written with the encoding which is specified in codingsystem= parameter. (when client codepage=932 (SJIS).) Samba can read this file correctly but SWAT can't treat these characters well when commiting from SWAT. It is fixed with this version.

Samba uses dos encoding (in this case, SJIS) as a internal encoding, and smb.conf, which is unix encoding (specified in codingsystem=) is converted to dos encoding while loading at lp_do_parameter(), add_a_service(). However, SWAT also uses these functions to commit parameters, which is not unix encoding. It causes miss conversion. And when SWAT writes parameters to smb.conf, show_parameter() is used but it is also used to show View Config page, while they might have different character codes. In this version, add-hoc fix has been done.

modified files
source/lib/kanji.c -
source/param/loadparm.c -
source/web/swat.c -

configure script & Makefile modification

configure.in, Makefile and some other files are modified to use gettext in swat.

portability

There are several implementation of message internationalization library such as Sun gettext, GNU gettext and XPG catgets. And system dependency of locale data was a problem. It may happens that (Japanese-enabled) web browser can't get Japanese data from SWAT if the server has no Japanese locale, because usually gettext uses locale data to change languages.

So I've decided to support only GNU gettext library included in the source code archive and to use environment variable to change languages instead of locale data, though it is not usual.

reference