From: Guillaume F. <gf...@lo...> - 2002-07-27 14:49:05
|
At 22:54 -0700 26/07/02, Craig Barratt wrote: >> In fact I would be pleased to help by contributing to the i18n effort. T= here >> is a gettext extension for perl that might look interesting. >> >> What would be the best way to make the i18n effort go in the official >> source? > >If you do it then I would be happy to merge it into the code. >Adding multilingual support would be excellent, although I have >no experience with internationalization issues. We could switch >to a templating system (eg: Template Toolkit) or simply extract >chunks of text from the CGI code and put them in a language >specific file. Guillaume Filion <gf...@lo...> knows a good >deal about this. I do? Oh yeah, the Mozilla i18n project... 8) I guess we should only translate the CGI interface (BackupPC_Admin), not the command line utilities. It seems to me that gettext or a template system are a bit overkill for just translating the CGI interface. We could just replace every string in english by a variable or a hash. This is not a big deal, but this would require some good elbow grease. So something like this: ----- if ( $In{doit} ) { if ( $start ) { if ( $Hosts->{$host}{dhcp} ) { $reply =3D $bpc->ServerMesg("backup $In{hostIP} $host" . " $User $doFull"); $str =3D "Backup requested on DHCP $host ($In{hostIP}) by" . " $User from $ENV{REMOTE_ADDR}"; } else { $reply =3D $bpc->ServerMesg("backup $host $host $User $doFull"); $str =3D "Backup requested on $host by $User"; } } else { $reply =3D $bpc->ServerMesg("stop $host $User $In{backoff}"); $str =3D "Backup stopped/dequeued on $host by $User"; } Header("BackupPC: Backup Requested on $host"); print <<EOF; ${h1($str)} <p> Reply from server was: $reply <p> Go back to <a href=3D"$MyURL?host=3D$host">$host home page</a>. EOF Trailer(); ----- Would look like this: ----- if ( $In{doit} ) { if ( $start ) { if ( $Hosts->{$host}{dhcp} ) { $reply =3D $bpc->ServerMesg("$lang{backup} $In{hostIP} $host" . " $User $doFull"); $str =3D "$lang{Backup_requested_on_DHCP} $host ($In{hostIP}) $lang{by}" . " $User $lang{from} $ENV{REMOTE_ADDR}"; } else { $reply =3D $bpc->ServerMesg("$lang{backup} $host $host $User $doFull"); $str =3D "$lang{Backup_requested_on} $host $lang{by} $User"; } } else { $reply =3D $bpc->ServerMesg("${stop} $host $User $In{backoff}")= ; $str =3D "$lang{Backup_stopped_dequeued_on} $host $lang{by} $Us= er"; } Header("BackupPC: $lang{Backup_requested_on} $host"); print <<EOF; ${h1($str)} <p> $lang{Reply_from_server_was} $reply <p> $lang{Go_back_to} <a href=3D"$MyURL?host=3D$host">$host $lang{home_page}</a>= =2E EOF Trailer(); ----- With a file en.pl that would contain: my %lang; $lang{backup} =3D "Backup"; $lang{Backup_requested_on_DHCP} =3D "Backup requested on DHCP"; $lang{by} =3D "by"; $lang{from} =3D "from"; $lang{Backup_requested_on} =3D "Backup Requested on"; $lang{stop} =3D "Stop"; $lang{Backup_stopped_dequeued_on} =3D "Backup stopped/dequeued on"; $lang{Reply_from_server_was} =3D "Reply from server was"; $lang{Go_back_to} =3D "Go back to"; $lang{home_page} =3D "home page"; And a file fr.pl that would contain: my %lang; $lang{backup} =3D "Sauvegarde"; $lang{Backup_requested_on_DHCP} =3D "Sauvegarde demand=E9e sur DHCP"; $lang{by} =3D "par"; $lang{from} =3D "de"; $lang{Backup_requested_on} =3D "Sauvegarde demand=E9e sur"; $lang{stop} =3D "Arr=EAter"; $lang{Backup_stopped_dequeued_on} =3D "Sauvegarde arr=EAt=E9e/d=E9command=E9e pour"; $lang{Reply_from_server_was} =3D "La r=E9ponse du serveur est"; $lang{Go_back_to} =3D "Retour =E0 la page de "; $lang{home_page} =3D ""; There's a structural problem with the last two variables, in english, we should read: Go back to $host home page. While in french, we should read: Retour =E0 la page de $host. So I made this little hack where the whole sentence is in $lang{Go_back_to}. It's not pretty, but it's the only simple solution if we don't put variable names in the l18n strings. Here are a few l18n tips: The main idea is to try to make it as readable as possible, for example I replace "Backup requested on DHCP" by $lang{Backup_requested_on_DHCP} Any char that can't be in a variable name is replaced by "_". It's usually not a good idea to simplify the variable names. Also, don't try to "optimise" it by doing things like: $lang{Backuprequested} $lang{on} DHCP because languages often have different structures, it may work in french and english, but may not in german or spanish. Each string should have its own variable. Even then you'll have structural problems like the "Go back to home page" I had in my small translation. =46or a french translation, http://www.granddictionnaire.com/ offers a terminological dictionary for technical (computer) terms. I considered localizing BackupPC in french, but it seemed to me like too much trouble for what it provided. Users usually only use it when they're desparate to have their files back; and in these times they would be willing to decypher something in ancient greek to have their files back. 8) On the other hand, I'd use a french version if there was one available... So if there are a few people interested, it might be a good task to undertake, but I'm not interested in doing it all by myself. GFK's -- Guillaume Filion Logidac Tech., Beaumont, Qu=E9bec, Canada - http://logidac.com/ PGP Key and more: http://guillaume.filion.org/ (this will redirect) PGP Fingerprint: 14A6 720A F7BA 6C87 2331 33FD 467E 9198 3DED D5CA |