Skip to content

Commit

Permalink
Added translations
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Apr 16, 2012
1 parent 6abd702 commit 5cfa4cf
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 21 deletions.
2 changes: 1 addition & 1 deletion contrib/lamework
15 changes: 15 additions & 0 deletions lib/Perliki.pm
Expand Up @@ -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;

Expand All @@ -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'
Expand All @@ -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));
Expand Down Expand Up @@ -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);
}
}
Expand Down
24 changes: 24 additions & 0 deletions lib/Perliki/I18N/ru.pm
@@ -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;
8 changes: 4 additions & 4 deletions templates/create.caml
@@ -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>
2 changes: 1 addition & 1 deletion templates/index.caml
@@ -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>
9 changes: 6 additions & 3 deletions templates/layout.caml
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions templates/login.caml
@@ -1,4 +1,4 @@
<h1>Login</h1>
<h1>{{#loc}}Login{{/loc}}</h1>

<form method="POST">
<div>
Expand All @@ -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>
2 changes: 1 addition & 1 deletion templates/not_found.caml
@@ -1 +1 @@
Not Foudn
Not Found
10 changes: 5 additions & 5 deletions templates/page.caml
Expand Up @@ -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}}
8 changes: 4 additions & 4 deletions templates/update.caml
@@ -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.