Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Locale-Maketext-Lexicon CPAN distribution.

Report information
The Basics
Id: 19711
Status: resolved
Priority: 0/
Queue: Locale-Maketext-Lexicon

People
Owner: Nobody in particular
Requestors: yann [...] sixapart.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.61
Fixed in: 0.61



Subject: [PATCH] Locale::Maketext::Lexicon's import broken in subclass usage
Hi Audrey, I noticed that in subclass usage, the %Lexicon doesn't get populated which makes Locale::Maketext to always fallback. Please, find attached a very short patch against version 0.61 (it's probably broken since long before). Bests, Yann
Subject: Locale-Maketext-Lexicon-0.61-import.patch
diff -u -r -N Locale-Maketext-Lexicon-0.61/lib/Locale/Maketext/Lexicon.pm Locale-Maketext-Lexicon-0.61.patched/lib/Locale/Maketext/Lexicon.pm --- Locale-Maketext-Lexicon-0.61/lib/Locale/Maketext/Lexicon.pm 2006-04-27 06:16:29.000000000 +0200 +++ Locale-Maketext-Lexicon-0.61.patched/lib/Locale/Maketext/Lexicon.pm 2006-06-05 19:30:36.000000000 +0200 @@ -231,7 +231,7 @@ # a hashref with $lang as keys, [$format, $src ...] as values %entries = %{$_[0]}; } - elsif (@_ % 2) { + elsif (@_ % 2 == 0) { %entries = ( '' => [ @_ ] ); } diff -u -r -N Locale-Maketext-Lexicon-0.61/t/99-bug-import-for-subclasses.t Locale-Maketext-Lexicon-0.61.patched/t/99-bug-import-for-subclasses.t --- Locale-Maketext-Lexicon-0.61/t/99-bug-import-for-subclasses.t 1970-01-01 01:00:00.000000000 +0100 +++ Locale-Maketext-Lexicon-0.61.patched/t/99-bug-import-for-subclasses.t 2006-06-05 19:36:07.000000000 +0200 @@ -0,0 +1,23 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 2; + +package Hello::I18N; +use base qw/Locale::Maketext/; + +package Hello::I18N::zh_tw; +use base qw/Hello::I18N/; +use Locale::Maketext::Lexicon ( Gettext => 't/messages.mo' ); + +package main; + +################################################################ + +ok(my $lh = Hello::I18N->get_handle('zh-tw'), 'got handle'); + +is( + $lh->maketext('This is a test'), + '這是測試', + 'translated' +); +
From: yannk [...] cpan.org
Show quoted text
> I noticed that in subclass usage, the %Lexicon doesn't get populated > which makes Locale::Maketext to always fallback. > > Yann
I've patched a bit further, because the options of the hash were ignored. Please find attached the updated patch, and test suite. Yann Kerhervé
diff -u -N -r Locale-Maketext-Lexicon-0.61/lib/Locale/Maketext/Lexicon.pm Locale-Maketext-Lexicon-0.61.patched/lib/Locale/Maketext/Lexicon.pm --- Locale-Maketext-Lexicon-0.61/lib/Locale/Maketext/Lexicon.pm 2006-04-27 06:16:29.000000000 +0200 +++ Locale-Maketext-Lexicon-0.61.patched/lib/Locale/Maketext/Lexicon.pm 2006-06-13 13:30:13.000000000 +0200 @@ -231,8 +231,8 @@ # a hashref with $lang as keys, [$format, $src ...] as values %entries = %{$_[0]}; } - elsif (@_ % 2) { - %entries = ( '' => [ @_ ] ); + elsif (@_ % 2 == 0) { + %entries = ( '' => [ splice @_, 0, 2 ], @_ ); } # expand the wildcard entry diff -u -N -r Locale-Maketext-Lexicon-0.61/t/99-bug-import-for-subclasses.t Locale-Maketext-Lexicon-0.61.patched/t/99-bug-import-for-subclasses.t --- Locale-Maketext-Lexicon-0.61/t/99-bug-import-for-subclasses.t 1970-01-01 01:00:00.000000000 +0100 +++ Locale-Maketext-Lexicon-0.61.patched/t/99-bug-import-for-subclasses.t 2006-06-13 13:51:44.000000000 +0200 @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 4; + +package Hello::I18N; +use base qw/Locale::Maketext/; + +package Hello::I18N::zh_tw; +use base qw/Hello::I18N/; +use Locale::Maketext::Lexicon ( Gettext => 't/messages.mo', ); + +package Hello::I18N::bzh_bzh; +use base qw/Hello::I18N/; +use Locale::Maketext::Lexicon ( Gettext => \*::DATA, _use_fuzzy => 1); + +package main; + +ok(my $lh = Hello::I18N->get_handle('zh-tw'), 'got handle'); + +is( + $lh->maketext('This is a test'), + '這是測試', + 'translated' +); + +ok($lh = Hello::I18N->get_handle('bzh_BZH'), 'Gettext - get_handle on DATA again'); +is( + eval { $lh->maketext("See you another time!") }, + "D'ur wech all !", + 'Gettext - fuzzy recognized: _use_fuzzy has been set' +); + +__DATA__ +msgid "" +msgstr "" +"Project-Id-Version: Test App 0.01\n" +"POT-Creation-Date: 2006-06-13 11:36+0800\n" +"PO-Revision-Date: 2006-06-13 02:00+0800\n" +"Last-Translator: <yannk@cpan.org>\n" +"Language-Team: German <yannk@cpan.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" + +#: Hello.pm:16 +#, big, furry, fuzzy +msgid "See you another time!" +msgstr "D'ur wech all !"