Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed I18N plugin bug that reads wrong I18N path when the app name in…

…cludes '::'
  • Loading branch information...
commit 679ab7af246bada41a5d27c088d2e76db1bb3568 1 parent f28c7ec
@typester authored
View
4 lib/Ark/Plugin/I18N.pm
@@ -13,7 +13,9 @@ sub BUILD {
return if $stash->{setup_finished};
my $class = ref($self->app);
- my $path = $self->path_to('lib', $class, 'I18N');
+ (my $module_path = $class) =~ s!::!/!g;
+
+ my $path = $self->path_to('lib', $module_path, 'I18N');
eval <<"";
package $class;
View
6 t/plugin_i18n/lib/TestApp/SubApp.pm
@@ -0,0 +1,6 @@
+package TestApp::SubApp;
+use Ark;
+
+use_plugins 'I18N';
+
+1;
View
9 t/plugin_i18n/lib/TestApp/SubApp/Controller.pm
@@ -0,0 +1,9 @@
+package TestApp::SubApp::Controller;
+use Ark 'Controller';
+
+sub hello :Local {
+ my ($self, $c) = @_;
+ $c->res->body( $c->localize('Hello') );
+}
+
+1;
View
22 t/plugin_i18n/lib/TestApp/SubApp/I18N/ja.po
@@ -0,0 +1,22 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2009-11-25 11:21+0900\n"
+"Last-Translator: Daisuke Murase <murase@kayac.com\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello"
+msgstr "こんにちは"
+
+#. ($c->user->obj->username)
+#: root/common/base.mt:18
+msgid "logined as %1"
+msgstr "%1 としてログインしています"
+
View
23 t/plugin_i18n_bug.t
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+use Test::More;
+
+use FindBin;
+use lib "$FindBin::Bin/plugin_i18n/lib";
+
+eval "require Locale::Maketext::Lexicon; require Locale::Maketext::Simple; 1";
+plan skip_all => 'Locale::Maketext::Lexicon required to run this test' if $@;
+
+use Ark::Test 'TestApp::SubApp';
+use HTTP::Request::Common;
+
+my $req = GET '/hello';
+$req->header('Accept-Language' => 'ja' );
+
+my $res = request $req;
+
+is $res->code, '200';
+is $res->content, 'こんにちは';
+
+done_testing;
+
Please sign in to comment.
Something went wrong with that request. Please try again.