From: Teemu A. <te...@io...> - 2004-07-29 20:16:20
|
Hi, OI 1.99_04 does not accept keys for localized messages that contain something else other than dots and alphanumerals (for example, space does not work). OpenInteract2::I18N::Initializer On line 138: my ( $key, $msg ) = $line =~ /^\s*([\w\.]+)\s*=\s*(.*)$/; Change to: my ( $key, $msg ) = $line =~ /^\s*(\S.+\S)\s*=\s*(.*)$/; .. because I prefer to have the actual english string as the key for easier translation: $self->_msg( "Operation failed: [_1]", $message ); Instead of something like: $self->_msg( "example.failed", $message ); More readable. For very long chunks of text I still prefer to use the translator unfriendly id key approach. Also, current localization framework is very bad at UTF-8. As of my knowledge Locale::Maketext is not multibyte safe. I'm also looking forward to a more standard implementation of the localization message file format, i.e. GNU gettext framework through Locale::Maketext::Gettext or Locale::Maketext::Lexicon. Implementation would require mapping bindtextdomain to packages locale/ directory (I would prefer that name instead of msg/), creating the directory structure under locale/ to follow standards (e.g. en/LC_MESSAGES/myapp.mo), using Locale::Maketext::* instead of Locale::Maketext and getting rid of the home-grown .msg reader in I18N::Initializer. Support for setting the encoding in package configuration would also be nice. gettext framework is multibyte safe, so this would help in creation of a chinese translation, for example. Extracting messages from perl source and creating the resulting PO files that are Maketext compatible could be achieved easily with Locale::Maketext::Extract and associated script xgettext.pl. Btw., here is a a script for extracting strings from the selected .pm sources and creating a file following the current format. It is not perfect. Expects that $self->_msg() is used at all times: --- #!/usr/bin/perl foreach $file (@ARGV) { next unless -f $file; open FILE, "< $file", or die "Can't open file $file: $!"; $out = undef; while (<FILE>) { if ( /_msg\(.*?['"](.+?)['"]/ ) { print $1 . " = " . $1 . "\n"; } } close FILE or die "Can't close file $file: $!"; } --- Example use would be something like: ./extract_msg_strings OpenInteract2/Action/* | sort | uniq > msg/locale-en.msg -- Teemu Arina Dicole project www.dicole.org |