![]() |
[ News | Documentation | Project | Event | Users Group | Mailing List ] |
JAPANESE | ENGLISH |
modification for the i18n of SWAT is written in this section.
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
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:
$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.
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.
source/web/neg_lang.c | - |
source/web/cgi.c | - |
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.
source/po/*.po | message catalogs |
source/web/swat.c | - |
source/web/statuspage.c | - |
source/param/loadparm.c | - |
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.
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.
source/lib/kanji.c | - |
source/param/loadparm.c | - |
source/web/swat.c | - |
configure.in, Makefile and some other files are modified to use gettext in swat.
source/configure.in
Two points are modified at nearly the end of the file.
# gettext support. # (added by rkawa) PACKAGE=i18n_swat AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_SUBST(PACKAGE) ALL_LINGUAS="en ja" AM_GNU_GETTEXT
PACKAGE is the name of the message catalog file. ALL_LINGUAS is the list of the language for which message catalogs are provided. That is, en.po, ja.po, ja_JP.SJIS.po files in source/po/ are processed. These files are converted to .mo files with msgfmt command while making and then, installed. AM_GNU_GETTEXT is the macro defined in source/aclocal.m4. This macro was copied from GNU gettext source and modified a little. It detects gettext or catgets library installed in the system, and checks the headers and libraries to compile GNU gettext library source in source/intl/.
AC_OUTPUT(include/stamp-h Makefile intl/Makefile po/Makefile.in)
New directories source/po, source/intl are created to support gettext. Makefiles in these directories are called from main Makefile and process their own directory separately. Both two files are copied from GNU gettext library source but modified to fit with Samba. (Samba has config.h in different directory with GNU standard directory structure.)
source/intl/Makefile.in
This directory contains GNU gettext library source code.
source/po/Makefile.in.in:
This directory contains data for i18n. Makefile processes .po (source) files and convert them to .mo (or .gmo) message catalog files, checks _("hoge") in source files and updates i18n_swat.pot, which is the template of the .po files. You can update .po files by merging (msgmerge command) them with i18n_swat.pot if new messages to be translated are added to source files.
source/po/POTFILES.in:
The list of the source files which has messages to be translated.
source/Makefile.in
top_builddir=. LIBS=@LIBS@ @INTLLIBS@# swat i18n with gettext
@INTLLIBS@ is set to gettext library by AM_GNU_GETTEXT macro explained before.
I18N_PACKAGE = @PACKAGE@ i18n_localedir = $(prefix)/@DATADIRNAME@/locale intlsubdirs = po intl top_srcdir = @top_srcdir@
i18n_localedir is the path to which gettext message catalogs are installed. intlsubdirs is the list of directories added for gettext support.
I18N-SUPPORT-ALL: I18N-SUPPORT-INSTALL: I18N-SUPPORT-CLEAN: I18N-SUPPORT-DISTCLEAN: I18N-SUPPORT-UNINSTALL:
These rules are made to call Makefiles in intlsubdirs
source/aclocal.m4:
AC_DEFUN(AM_WITH_NLS, AC_DEFUN(AM_GNU_GETTEXT, AC_DEFUN(AM_LC_MESSAGES, AC_DEFUN(AM_PATH_PROG_WITH_TEST,
These macros are copied from aclocal.m4 file in GNU gettext source to support autoconf and check libraries and headers related to gettext.
source/acconfig.h:
ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_LC_MESSAGES, HAVE_STPCPY, PACKAGE : These are added to support autoconf and necessary to compile GNU gettext library.
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.