Permalink
Browse files

Added translations

  • Loading branch information...
1 parent 6abd702 commit 5cfa4cfc66b2008546aca3247b98f8445f1f5a90 @vti committed Apr 16, 2012
View
@@ -10,6 +10,7 @@ use Lamework::ActionFactory;
use Lamework::Dispatcher::Routes;
use Lamework::Displayer;
use Lamework::HelperFactory;
+use Lamework::I18N;
use Lamework::Renderer::Caml;
use Lamework::Routes;
@@ -28,6 +29,8 @@ sub startup {
Perliki::DB->init_db(%{$config->{database}});
+ my $i18n = Lamework::I18N->new(app_class => __PACKAGE__);
+
my $displayer = Lamework::Displayer->new(
renderer => Lamework::Renderer::Caml->new(home => $self->{home}),
layout => 'layout.caml'
@@ -53,6 +56,8 @@ sub startup {
expires => $self->{config}->{session}->{expires}
);
+ $self->add_middleware('I18N', i18n => $i18n);
+
$self->add_middleware('RequestDispatcher',
dispatcher =>
Lamework::Dispatcher::Routes->new(routes => $self->_build_routes));
@@ -91,6 +96,16 @@ sub startup {
$env->{'lamework.displayer.vars'}->{'title'} = $config->{wiki}->{title};
+ my $languages_names = $i18n->get_languages_names;
+ if (keys %$languages_names > 1) {
+ $env->{'lamework.displayer.vars'}->{'languages'} =
+ [map { {code => $_, name => $languages_names->{$_}} }
+ keys %$languages_names];
+ }
+
+ $env->{'lamework.displayer.vars'}->{'loc'} =
+ sub { shift; $env->{'lamework.i18n.maketext'}->loc(@_) };
+
return $app->($env);
}
}
View
@@ -0,0 +1,24 @@
+package Perliki::I18N::ru;
+
+use strict;
+use warnings;
+use utf8;
+
+use base 'Perliki::I18N';
+
+our %Lexicon = (
+ 'Login' => 'Вход',
+ 'Logout' => 'Выход',
+ 'Last changes' => 'Последние изменения',
+ 'All pages' => 'Все страницы',
+ 'Last modification' => 'Последнее изменение',
+ 'by' => 'от',
+ 'update' => 'изменить',
+ 'Update' => 'Изменить',
+ 'Create' => 'Создать',
+ 'Preview' => 'Предпросмотр',
+ 'last modification' => 'последнее изменение',
+ 'history' => 'история',
+);
+
+1;
View
@@ -1,18 +1,18 @@
{{#preview}}
-<h1>Preview</h1>
+<h1>{{#loc}}Preview{{/loc}}</h1>
<div>
{{&page.content_rendered}}
</div>
{{/preview}}
-<h1>Create page</h1>
+<h1>{{#loc}}Create page{{/loc}}</h1>
<form method="POST">
<div>
<textarea name="content">{{form.content}}</textarea>
{{#errors.content}}{{errors.content}}{{/errors.content}}
</div>
<div>
- <input type="submit" name="preview" value="Preview" />
- <input type="submit" name="submit" value="Create" />
+ <input type="submit" name="preview" value="{{#loc}}Preview{{/loc}}" />
+ <input type="submit" name="submit" value="{{#loc}}Create{{/loc}}" />
</div>
</form>
View
@@ -1,3 +1,3 @@
<h1>Perliki</h1>
- <a href="/wiki/Index">Create Index page</a>
+ <a href="/wiki/Index">{{#loc}}Create Index page{{/loc}}</a>
View
@@ -26,13 +26,16 @@
<div class="twocol">
</div>
<div class="eightcol">
- <a href="/wiki/Index">Index</a> | <a href="/changes">Last changes</a> | <a href="/wiki/">All pages</a>
+ <a href="/wiki/Index">Index</a> | <a href="/changes">{{#loc}}Last changes{{/loc}}</a> | <a href="/wiki/">{{#loc}}All pages{{/loc}}</a>
<div style="float:right">
+ {{#languages}}
+ <a href="/{{code}}">{{name}}</a>
+ {{/languages}}
{{#user}}
- <a href="/logout">Logout ({{name}})</a>
+ | <a href="/logout">{{#loc}}Logout{{/loc}} ({{name}})</a>
{{/user}}
{{^user}}
- <a href="/login">Login</a>
+ <a href="/login">{{#loc}}Login{{/loc}}</a>
{{/user}}
</div>
<div style="clear:both"></div>
View
@@ -1,4 +1,4 @@
-<h1>Login</h1>
+<h1>{{#loc}}Login{{/loc}}</h1>
<form method="POST">
<div>
@@ -10,6 +10,6 @@
{{#errors.password}}{{errors.password}}{{/errors.password}}
</div>
<div>
- <input type="submit" name="submit" value="Login" />
+ <input type="submit" name="submit" value="{{#loc}}Login{{/loc}}" />
</div>
</form>
View
@@ -1 +1 @@
-Not Foudn
+Not Found
View
@@ -3,17 +3,17 @@
</div>
<hr />
-<div>Last modification: {{#helpers.date.format}}{{page.updated}}{{/helpers.date.format}} by {{page.user.name}}</div>
+<div>{{#loc}}Last modification{{/loc}}: {{#helpers.date.format}}{{page.updated}}{{/helpers.date.format}} {{#loc}}by{{/loc}} {{page.user.name}}</div>
{{#user}}
-<a href="/update/{{page.name}}">update</a>
+<a href="/update/{{page.name}}">{{#loc}}update{{/loc}}</a>
{{/user}}
{{#page.has_history}}
-<a href="/diff/{{page.name}}">last modification</a>
-<a href="/history/{{page.name}}">history</a>
+<a href="/diff/{{page.name}}">{{#loc}}last modification{{/loc}}</a>
+<a href="/history/{{page.name}}">{{#loc}}history{{/loc}}</a>
{{/page.has_history}}
{{#user1}}
-<a href="/delete/{{page.name}}">delete</a>
+<a href="/delete/{{page.name}}">{{#loc}}delete{{/loc}}</a>
{{/user1}}
View
@@ -1,20 +1,20 @@
&larr; <a href="/wiki/{{page.name}}">{{page.name}}</a>
{{#preview}}
-<h1>Preview</h1>
+<h1>{{#loc}}Preview{{/loc}}</h1>
<div>
{{&page.content_rendered}}
</div>
{{/preview}}
-<h1>Update</h1>
+<h1>{{#loc}}Update{{/loc}}</h1>
<form method="POST">
<div>
<textarea name="content">{{form.content}}</textarea>
{{#errors.content}}{{errors.content}}{{/errors.content}}
</div>
<div>
- <input type="submit" name="preview" value="Preview" />
- <input type="submit" name="submit" value="Update" />
+ <input type="submit" name="preview" value="{{#loc}}Preview{{/loc}}" />
+ <input type="submit" name="submit" value="{{#loc}}Update{{/loc}}" />
</div>
</form>

0 comments on commit 5cfa4cf

Please sign in to comment.