[Jifty-commit] r782 - in jifty/trunk: . lib lib/Jifty lib/Jifty/Script lib/Jifty/View/Mason lib/Jifty/Web/Form lib/Jifty/Web/Form/Field share/web/templates share/web/templates/__jifty share/web/templates/__jifty/online_docs share/web/templates/_elements share/web/templates/helpers

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Mar 31 08:22:29 EST 2006


Author: jesse
Date: Fri Mar 31 08:22:15 2006
New Revision: 782

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/Makefile.PL
   jifty/trunk/lib/Jifty.pm
   jifty/trunk/lib/Jifty/I18N.pm
   jifty/trunk/lib/Jifty/Record.pm
   jifty/trunk/lib/Jifty/Script/App.pm
   jifty/trunk/lib/Jifty/View/Mason/Handler.pm
   jifty/trunk/lib/Jifty/Web.pm
   jifty/trunk/lib/Jifty/Web/Form/Field.pm
   jifty/trunk/lib/Jifty/Web/Form/Field/Button.pm
   jifty/trunk/lib/Jifty/Web/Form/Link.pm
   jifty/trunk/share/web/templates/__jifty/admin/index.html
   jifty/trunk/share/web/templates/__jifty/edit_file
   jifty/trunk/share/web/templates/__jifty/online_docs/content.html
   jifty/trunk/share/web/templates/__jifty/online_docs/index.html
   jifty/trunk/share/web/templates/__jifty/online_docs/toc.html
   jifty/trunk/share/web/templates/_elements/header
   jifty/trunk/share/web/templates/_elements/menu
   jifty/trunk/share/web/templates/_elements/sidebar
   jifty/trunk/share/web/templates/_elements/wrapper
   jifty/trunk/share/web/templates/dhandler
   jifty/trunk/share/web/templates/helpers/calendar.html
   jifty/trunk/share/web/templates/index.html

Log:
 r10982 at hualien:  jesse | 2006-03-31 22:07:26 +0900
 * First pass localization


Modified: jifty/trunk/Makefile.PL
==============================================================================
--- jifty/trunk/Makefile.PL	(original)
+++ jifty/trunk/Makefile.PL	Fri Mar 31 08:22:15 2006
@@ -33,7 +33,7 @@
 requires('Hash::Merge');
 requires('Hook::LexWrap');
 requires('Jifty::DBI' => '0.16' );            # Jifty::DBI::Collection Jifty::DBI::Handle Jifty::DBI::Record::Cachable Jifty::DBI::SchemaGenerator
-requires('Locale::Maketext::Simple');
+requires('Locale::Maketext::Lexicon');
 requires('Log::Log4perl');
 requires('LWP::UserAgent');
 requires('MIME::Types');

Modified: jifty/trunk/lib/Jifty.pm
==============================================================================
--- jifty/trunk/lib/Jifty.pm	(original)
+++ jifty/trunk/lib/Jifty.pm	Fri Mar 31 08:22:15 2006
@@ -2,6 +2,7 @@
 use strict;
 
 package Jifty;
+use encoding 'utf8';
 
 our $VERSION = '0.60321';
 

Modified: jifty/trunk/lib/Jifty/I18N.pm
==============================================================================
--- jifty/trunk/lib/Jifty/I18N.pm	(original)
+++ jifty/trunk/lib/Jifty/I18N.pm	Fri Mar 31 08:22:15 2006
@@ -11,7 +11,7 @@
 
 =head1 METHODS
 
-=head2 C<loc> /  C<_>
+=head2 C<_>
 
 This module exports the C<loc> method, which it inherits from
 L<Locale::Maketext::Simple>. Jifty aliases this method to C<_()> for 
@@ -20,18 +20,28 @@
 =cut
 
 
+=head2 new
+
+Set up Jifty's internationalization for your application.  This pulls
+in Jifty's PO files, your PO files and then exports the _ function into
+the wider world.
+
+=cut
+
+
 sub new {
     my $class = shift;
     my $self  = {};
     bless $self, $class;
 
     Locale::Maketext::Lexicon->import(
-        {
-        '*' => [
-            Gettext => Jifty->config->framework('L10N')->{'PoDir'} . '/*.po',
-            Gettext => Jifty->config->framework('L10N')->{'DefaultPoDir'} . '/*.po'
-        ],
-            
+        {   '*' => [
+                Gettext => Jifty->config->framework('L10N')->{'PoDir'}
+                    . '/*.po',
+                Gettext => Jifty->config->framework('L10N')->{'DefaultPoDir'}
+                    . '/*.po'
+            ],
+
             _decode => 1,
         }
     );
@@ -41,10 +51,11 @@
 
     my $lh         = eval { $class->get_handle };
     my $loc_method = sub  { $lh->maketext(@_); };
-    no strict 'refs';
-    *{ caller(0) . "::loc" } = $loc_method;
-    *_ = \&{ caller(0) . "::loc" };
-    warn "here for " . caller(0);
+    {
+        no strict 'refs';
+        no warnings 'redefine';
+        *_ = $loc_method;
+    }
     return $self;
 }
 

Modified: jifty/trunk/lib/Jifty/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Record.pm	(original)
+++ jifty/trunk/lib/Jifty/Record.pm	Fri Mar 31 08:22:15 2006
@@ -58,7 +58,7 @@
     unless ( $self->check_create_rights(@_) ) {
         $self->log->error( $self->current_user->id . " tried to create a ",
             ref $self, " without permission" );
-        wantarray ? return ( 0, 'Permission denied' ) : return (0);
+        wantarray ? return ( 0, _('Permission denied') ) : return (0);
     }
 
     foreach my $key ( keys %attribs ) {
@@ -80,7 +80,7 @@
 
     my($id,$msg) = $self->SUPER::create(%attribs);
     $self->load_by_cols( id => $id ) if ($id);
-    return wantarray ? ( $id, "Record created" ) : $id;
+    return wantarray ? ( $id, _("Record created") ) : $id;
 }
 
 
@@ -219,7 +219,7 @@
 
     unless ($self->check_update_rights(@_)) {
         Jifty->log->logcluck("Permission denied");
-        return (0, 'Permission denied');
+        return (0, _('Permission denied'));
     }
     $self->SUPER::_set(@_);
 }
@@ -278,7 +278,7 @@
     my $self = shift;
     unless ($self->check_delete_rights(@_)) {
             Jifty->log->logcluck("Permission denied");
-            return(0, 'Permission denied');
+            return(0, _('Permission denied'));
         }
     $self->SUPER::delete(@_); 
 }

Modified: jifty/trunk/lib/Jifty/Script/App.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/App.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/App.pm	Fri Mar 31 08:22:15 2006
@@ -123,6 +123,7 @@
         var
         var/sessions
         var/mason
+        share
         share/po
         share/web
         share/web/templates

Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm	Fri Mar 31 08:22:15 2006
@@ -83,7 +83,8 @@
     if ($r->content_type =~ /charset=([\w-]+)$/ ) {
         my $enc = $1;
 	if (lc($enc) =~ /utf-?8/) {
-            binmode *STDOUT, ":utf8";
+            # XXX TODO: utf8 binmode breaks things right now
+            #    binmode *STDOUT, ":utf8";
 	}
 	else {
             binmode *STDOUT, ":encoding($enc)";

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Fri Mar 31 08:22:15 2006
@@ -210,7 +210,7 @@
 
 sub handle_request {
     my $self = shift;
-    die "No request to handle" unless Jifty->web->request;
+    die _( "No request to handle" ) unless Jifty->web->request;
 
     my @valid_actions;
     for my $request_action ( $self->request->actions ) {

Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm	Fri Mar 31 08:22:15 2006
@@ -358,7 +358,7 @@
 sub render_preamble {
     my $self = shift;
     Jifty->web->out(
-qq!<span class="preamble @{[$self->classes]}" >@{[$self->preamble || '' ]}</span>\n!
+qq!<span class="preamble @{[$self->classes]}" >@{[_($self->preamble) || '' ]}</span>\n!
     );
 
     return '';
@@ -375,7 +375,7 @@
 sub render_label {
     my $self = shift;
     Jifty->web->out(
-qq!<label class="label @{[$self->classes]}" for="@{[$self->input_name ]}">@{[$self->label ]}</label>\n!
+qq!<label class="label @{[$self->classes]}" for="@{[$self->input_name ]}">@{[_($self->label) ]}</label>\n!
     );
 
     return '';
@@ -443,7 +443,7 @@
     my $self  = shift;
     my $field = '<span';
     $field .= qq! class="@{[ $self->classes ]}"> !;
-    $field .= HTML::Entities::encode_entities($self->current_value) if defined $self->current_value;
+    $field .= HTML::Entities::encode_entities(_($self->current_value)) if defined $self->current_value;
     $field .= qq!</span>\n!;
     Jifty->web->out($field);
     return '';

Modified: jifty/trunk/lib/Jifty/Web/Form/Field/Button.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field/Button.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field/Button.pm	Fri Mar 31 08:22:15 2006
@@ -18,7 +18,7 @@
         '<input',
         'type="submit"',
         'name="' . $self->input_name . '" ',
-        'value="' . $self->label . '"',
+        'value="' . _($self->label ). '"',
         $self->_widget_class('button'),
         $self->javascript,
         ' />',

Modified: jifty/trunk/lib/Jifty/Web/Form/Link.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Link.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Link.pm	Fri Mar 31 08:22:15 2006
@@ -104,7 +104,7 @@
     Jifty->web->out(qq( title="@{[$self->tooltip]}")) if $tooltip;
     Jifty->web->out(qq( href="@{[$self->url]}"));
     Jifty->web->out( $self->javascript() );
-    Jifty->web->out(qq(>@{[$label]}</a>));
+    Jifty->web->out(qq(>@{[_($label)]}</a>));
     $self->render_key_binding();
 
     return ('');

Modified: jifty/trunk/share/web/templates/__jifty/admin/index.html
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/admin/index.html	(original)
+++ jifty/trunk/share/web/templates/__jifty/admin/index.html	Fri Mar 31 08:22:15 2006
@@ -30,11 +30,11 @@
 </%init>
 <&|/_elements/wrapper, title => 'Jifty Administrative Console' &>
 
-<h1>Database Administration</h1>
+<h1><%_('Database Administration')%></h1>
 
-<p>This console lets you manage the records in your Jifty database. Below, you should see a list of all your database tables. Feel free to go through and add, delete or modify records.</p>
+<p><%_('This console lets you manage the records in your Jifty database. Below, you should see a list of all your database tables. Feel free to go through and add, delete or modify records.')%></p>
 
-<p>To disable this administrative console, add "framework: AdminMode: 0" to your application's configuration file.</p>
+<p><%_('To disable this administrative console, add "framework: AdminMode: 0" to your application's configuration file.')%></p>
     
 
 <ul>

Modified: jifty/trunk/share/web/templates/__jifty/edit_file
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/edit_file	(original)
+++ jifty/trunk/share/web/templates/__jifty/edit_file	Fri Mar 31 08:22:15 2006
@@ -3,7 +3,7 @@
 $editor => undef
 </%args>
 <%init>
-my $title = "Editing file ".$editor->argument_value('source_path');
+my $title = _("Editing file [_1]",$editor->argument_value('source_path'));
 </%init>
 <&|/_elements/wrapper, title => $title &>
 <% Jifty->web->form->start %>

Modified: jifty/trunk/share/web/templates/__jifty/online_docs/content.html
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/online_docs/content.html	(original)
+++ jifty/trunk/share/web/templates/__jifty/online_docs/content.html	Fri Mar 31 08:22:15 2006
@@ -3,7 +3,7 @@
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
 <head>
-<title><% $n || 'Jifty' %> - Jifty Pod Online</title>
+<title><% _( $n || 'Jifty') %> - <%_('Jifty Pod Online')%></title>
 <style type="text/css"><!--
 a { text-decoration: none }
 a:hover { text-decoration: underline }
@@ -45,7 +45,7 @@
 $body =~ s{</body>\s*</html>\s*$}{};
 $n    =~ s{/}{::}g;
 $m->print("<h1>$n</h1>");
-$m->print("<h2>Schema</h2><pre>$schema</pre>") if ($schema);
+$m->print("<h2><%_('Schema')%></h2><pre>$schema</pre>") if ($schema);
 $body =~ s{<a href="http://search\.cpan\.org/perldoc\?(Jifty%3A%3A[^"]+)"([^>]*)>}{<a href="content.html?n=$1"$2>}g;
 $body =~ s!</li>\n\t<ul>!<ul>!;
 $body =~ s!</ul>!</ul></li>!;

Modified: jifty/trunk/share/web/templates/__jifty/online_docs/index.html
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/online_docs/index.html	(original)
+++ jifty/trunk/share/web/templates/__jifty/online_docs/index.html	Fri Mar 31 08:22:15 2006
@@ -2,7 +2,7 @@
 "http://www.w3.org/TR/html4/">
 <html lang="en">
 <head>
-<title><% $n || 'Jifty' %> - Online Documentation</title>
+<title><%_( $n || 'Jifty') %> - <%_('Online Documentation')%></title>
 <style type="text/css"><!--
 a { text-decoration: none }
 a:hover { text-decoration: underline }
@@ -13,9 +13,9 @@
     <FRAME src="./content.html" name="podcontent">
     <FRAME src="./toc.html" name="podtoc">
     <NOFRAMES>
-        <a style="display: none" href="#toc">Table of Contents</a>
+        <a style="display: none" href="#toc"><%_('Table of Contents')%></a>
 <& content.html, Target => '' &>
-        <h1><a id="toc">Table of Contents</a></h1>
+        <h1><a id="toc"><%_('Table of Contents')%></a></h1>
 <& toc.html, Target => '' &>
     </NOFRAMES>
 </FRAMESET>

Modified: jifty/trunk/share/web/templates/__jifty/online_docs/toc.html
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/online_docs/toc.html	(original)
+++ jifty/trunk/share/web/templates/__jifty/online_docs/toc.html	Fri Mar 31 08:22:15 2006
@@ -3,7 +3,7 @@
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
 <head>
-<title><% $n || 'Jifty' %> - Jifty Developer Documentation Online</title>
+<title><% _($n || 'Jifty') %> - <%_('Jifty Developer Documentation Online')%></title>
 <style type="text/css"><!--
 a { text-decoration: none }
 a:hover { text-decoration: underline }

Modified: jifty/trunk/share/web/templates/_elements/header
==============================================================================
--- jifty/trunk/share/web/templates/_elements/header	(original)
+++ jifty/trunk/share/web/templates/_elements/header	Fri Mar 31 08:22:15 2006
@@ -4,7 +4,7 @@
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   <meta name="robots" content="all" />
   
-  <title><% $title %></title>
+  <title><% _($title) %></title>
   
   <link rel="stylesheet" type="text/css" href="/static/css/main.css" media="all" />
   <& javascript &> 

Modified: jifty/trunk/share/web/templates/_elements/menu
==============================================================================
--- jifty/trunk/share/web/templates/_elements/menu	(original)
+++ jifty/trunk/share/web/templates/_elements/menu	Fri Mar 31 08:22:15 2006
@@ -23,7 +23,7 @@
   <li <%  $item->active ? 'class="active"' : '' |n %>><%
     Jifty->web->link(
         url   => $item->url,
-        label => $item->label,
+        label => _($item->label),
     ) %><% @kids ? '' : '</li>' |n %>
 % if (@kids) {
     <ul class="submenu">

Modified: jifty/trunk/share/web/templates/_elements/sidebar
==============================================================================
--- jifty/trunk/share/web/templates/_elements/sidebar	(original)
+++ jifty/trunk/share/web/templates/_elements/sidebar	Fri Mar 31 08:22:15 2006
@@ -1,8 +1,8 @@
 <div id="salutation">
 % if (Jifty->web->current_user->id and Jifty->web->current_user->user_object) {
-Hiya, <span class="user"><%Jifty->web->current_user->user_object->name%></span>.
+<%_('Hiya, <span class="user">[_1]</span>.',Jifty->web->current_user->user_object->name)%>
 % }  else {
-You're not currently signed in. 
+<%_(q{You're not currently signed in.})%>
 % }
 </div>
 <div id="navigation">

Modified: jifty/trunk/share/web/templates/_elements/wrapper
==============================================================================
--- jifty/trunk/share/web/templates/_elements/wrapper	(original)
+++ jifty/trunk/share/web/templates/_elements/wrapper	Fri Mar 31 08:22:15 2006
@@ -1,14 +1,14 @@
 <body>
   <div id="headers">
-    <%Jifty->web->link( url => "/", label => Jifty->config->framework('ApplicationName'))%>
-    <h1 class="title"><% $title %></h1>
+    <%Jifty->web->link( url => "/", label => _(Jifty->config->framework('ApplicationName')))%>
+    <h1 class="title"><% _($title) %></h1>
   </div>
   <& sidebar &>
   <div id="content">
     <a name="content"></a>
 % if (Jifty->config->framework('AdminMode') ) {
 <div class="warning admin_mode">
-Alert: Jifty <% Jifty->web->tangent( label => 'administration mode' , url => '/__jifty/admin/')%> is enabled.
+<%_('Alert')%>: <% Jifty->web->tangent( label => _('Administration mode is enabled.') , url => '/__jifty/admin/')%>
 </div>
 % }
   <% Jifty->web->render_messages %>
@@ -17,7 +17,7 @@
   document.write('<div id="keybindings">');
   writeKeyBindingLegend();
   document.write('<\/div>');
-  document.write('<div id="jifty-wait-message" style="display: none">Loading...<\/div>');
+  document.write('<div id="jifty-wait-message" style="display: none"><%_('Loading...')%><\/div>');
   --></script>
 % Jifty::Mason::Halo->render_component_tree() if (Jifty->config->framework('DevelMode') );
 </body>

Modified: jifty/trunk/share/web/templates/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/dhandler	(original)
+++ jifty/trunk/share/web/templates/dhandler	Fri Mar 31 08:22:15 2006
@@ -1,14 +1,13 @@
-<&| /_elements/wrapper, title => "Something's not quite right" &>
+<&| /_elements/wrapper, title => _("Something's not quite right") &>
 
 <div id="overview">
 
-<p>You got to a page that we don't think exists.  Anyway, the software has logged this error. Sorry about this.</p>
+<p><%_("You got to a page that we don't think exists.  Anyway, the software has logged this error. Sorry about this.")%></p>
 
-<p><%Jifty->web->link( url => "/", label => 'Go back home...')%></p>
+<p><%Jifty->web->link( url => "/", label => _('Go back home...'))%></p>
 
 </div>
 </&>
-%# XXX TODO ACTUALLY LOG THIS.
 <%doc>
 Used as a poor man's 404 handler
 </%doc>

Modified: jifty/trunk/share/web/templates/helpers/calendar.html
==============================================================================
--- jifty/trunk/share/web/templates/helpers/calendar.html	(original)
+++ jifty/trunk/share/web/templates/helpers/calendar.html	Fri Mar 31 08:22:15 2006
@@ -1,18 +1,18 @@
 <& /_elements/header, title => 'Calendar' &>
 <body class="calpopup">
 
-<a href="#" onclick="window.close(); return false;">Close window</a>
+<a href="#" onclick="window.close(); return false;"><% _('Close window')%></a>
 
 <div class="calendar">
   <table>
     <caption>
       <a class="prev" href="calendar.html?DisplayedMonth=<%$prev_month%>&DisplayedYear=<%$prev_year%>&field=<%$field%>">Prev</a>
-      <span class="month"><% $months[$DisplayedMonth-1] %> <% $DisplayedYear %></span>
+      <span class="month"><% $months[$DisplayedMonth-1] %> <% _($DisplayedYear) %></span>
       <a class="next" href="calendar.html?DisplayedMonth=<%$next_month%>&DisplayedYear=<%$next_year%>&field=<%$field%>">Next</a>
     </caption>
     <tr>
 % foreach my $wday (@weekdays) {
-      <th><%$wday%></th>
+      <th><%_($wday)%></th>
 % }
     </tr>
 % foreach my $week (@cal) {

Modified: jifty/trunk/share/web/templates/index.html
==============================================================================
--- jifty/trunk/share/web/templates/index.html	(original)
+++ jifty/trunk/share/web/templates/index.html	Fri Mar 31 08:22:15 2006
@@ -1,5 +1,4 @@
 <&|/_elements/wrapper, title => _('Welcome to your new Jifty application') &>
-<img src="/static/images/pony.jpg" alt="You said you wanted a pony. (Source http://hdl.loc.gov/loc.pnp/cph.3c13461)" />
-
-<%_('Pony')%>
+<img src="/static/images/pony.jpg" 
+     alt="<%_('You said you wanted a pony. (Source [_1])','http://hdl.loc.gov/loc.pnp/cph.3c13461')%>" />
 </&>


More information about the Jifty-commit mailing list