[MKDoc-commit] [1.6] backported gettext translation system from 1.8
bruno at mkdoc.demon.co.uk
bruno at mkdoc.demon.co.uk
Thu Feb 9 16:53:22 GMT 2006
Log Message:
-----------
[1.6] backported gettext translation system from 1.8
Tags:
----
mkdoc-1-6
Modified Files:
--------------
mkd/flo:
Component.pm
Editor.pm
Plugin.pm
Standard.pm
mkd/flo/editor:
Comment.pm
RSS.pm
mkd/templates/fragments/search:
en.html
Added Files:
-----------
mkd/MKDoc:
Template.pm
-------------- next part --------------
--- /dev/null
+++ MKDoc/Template.pm
@@ -0,0 +1,33 @@
+package MKDoc::Template;
+use warnings;
+use strict;
+use Petal;
+use Petal::TranslationService::Gettext;
+use Petal::TranslationService::Noop;
+
+
+sub new
+{
+ my $class = shift;
+ my $tmpl = Petal->new (@_);
+
+ $Petal::TranslationService = (-e "$ENV{SITE_DIR}/locale") ?
+
+ Petal::TranslationService::Gettext->new (
+ locale_dir => "$ENV{SITE_DIR}/locale",
+ target_lang => $tmpl->language() || 'en',
+ ) :
+
+ Petal::TranslationService::Gettext->new (
+ locale_dir => "$ENV{MKDOC_DIR}/locale",
+ target_lang => $tmpl->language() || 'en',
+ );
+
+ return $tmpl;
+}
+
+
+1;
+
+
+__END__
Index: Standard.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Standard.pm,v
retrieving revision 1.12.2.13
retrieving revision 1.12.2.14
diff -Lflo/Standard.pm -Lflo/Standard.pm -u -r1.12.2.13 -r1.12.2.14
--- flo/Standard.pm
+++ flo/Standard.pm
@@ -33,6 +33,7 @@
# -------------------------------------------------------------------------------------
package flo::Standard;
use MKDoc::Config;
+use MKDoc::Template;
use lib::sql::Table;
use MKDoc::CGI;
use Exporter;
Index: Plugin.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Plugin.pm,v
retrieving revision 1.22.2.37
retrieving revision 1.22.2.38
diff -Lflo/Plugin.pm -Lflo/Plugin.pm -u -r1.22.2.37 -r1.22.2.38
--- flo/Plugin.pm
+++ flo/Plugin.pm
@@ -29,7 +29,6 @@
use flo::Standard;
use flo::HTTP::Header;
use MKDoc::Ouch;
-use Petal;
use strict;
use warnings;
use Carp;
@@ -618,7 +617,7 @@
$Petal::INPUT = $hash->{__input__} || 'XML';
$Petal::OUTPUT = $hash->{__output__} || 'XML';
- my $template = new Petal
+ my $template = new MKDoc::Template
language => $self->language(),
file => $self->template_path();
Index: Component.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Component.pm,v
retrieving revision 1.3.2.39
retrieving revision 1.3.2.40
diff -Lflo/Component.pm -Lflo/Component.pm -u -r1.3.2.39 -r1.3.2.40
--- flo/Component.pm
+++ flo/Component.pm
@@ -311,7 +311,7 @@
{
my $self = shift;
my $type = $self->type();
- my $tmpl = new Petal ( file => "editor/$type", lang => $self->language() );
+ my $tmpl = new MKDoc::Template ( file => "editor/$type", lang => $self->language() );
my $res = $tmpl->process ( self => $self );
Encode::_utf8_on ($res);
return $res;
@@ -795,7 +795,7 @@
{
my $self = shift;
my $type = $self->type();
- my $template = new Petal (
+ my $template = new MKDoc::Template (
file => "component/$type",
lang => $self->language(),
input => 'XML',
Index: Editor.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Editor.pm,v
retrieving revision 1.12.2.49
retrieving revision 1.12.2.50
diff -Lflo/Editor.pm -Lflo/Editor.pm -u -r1.12.2.49 -r1.12.2.50
--- flo/Editor.pm
+++ flo/Editor.pm
@@ -753,7 +753,7 @@
# build the add component box
my $doc = flo::Standard::current_document();
- my $tmpl = new Petal ( file => 'editor/box', lang => $doc->language() );
+ my $tmpl = new MKDoc::Template ( file => 'editor/box', lang => $doc->language() );
push @out, $tmpl->process ( option_list => \@add, document => $doc );
return join "\n", @out;
}
Index: Comment.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Comment.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lflo/editor/Comment.pm -Lflo/editor/Comment.pm -u -r1.1.2.1 -r1.1.2.2
--- flo/editor/Comment.pm
+++ flo/editor/Comment.pm
@@ -69,7 +69,7 @@
$self->{'comment'} = MKDoc::XML::Tagger::Preserve->process_data (['a'], $data, @newl);
my $type = $self->type();
- my $template = new Petal (
+ my $template = new MKDoc::Template (
file => "component/$type",
lang => $self->language(),
input => 'XML',
Index: RSS.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/RSS.pm,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -Lflo/editor/RSS.pm -Lflo/editor/RSS.pm -u -r1.1.2.10 -r1.1.2.11
--- flo/editor/RSS.pm
+++ flo/editor/RSS.pm
@@ -27,6 +27,7 @@
use MKDoc::HTTP::Response;
use Cache::FileCache;
use XML::RSS;
+use MKDoc::Template;
use Encode;
@@ -355,7 +356,7 @@
my $self = shift;
my $type = $self->type();
my $tmpl = $self->template();
- my $template = new Petal (
+ my $template = new MKDoc::Template (
file => "component/$type/$tmpl",
lang => $self->language(),
input => 'XML',
Index: en.html
===================================================================
RCS file: /var/spool/cvs/mkd/templates/fragments/search/Attic/en.html,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -Ltemplates/fragments/search/en.html -Ltemplates/fragments/search/en.html -u -r1.1.2.8 -r1.1.2.9
--- templates/fragments/search/en.html
+++ templates/fragments/search/en.html
@@ -7,6 +7,8 @@
<div
class="search"
petal:condition="search_uri"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="mkdoc"
xmlns:petal="http://purl.org/petal/1.0/"
>
<form
@@ -30,6 +32,10 @@
xml:lang="en"
lang="en"
dir="ltr"
+ i18n:attributes="xml:lang two-letter-language-code;
+ lang two-letter-language-code;
+ dir text-direction;"
+ i18n:translate="search-label"
>Search</span>
<span
xml:lang="en"
More information about the MKDoc-commit
mailing list