Changeset 1546


Ignore:
Timestamp:
12/28/15 15:45:11 (8 years ago)
Author:
nanardon
Message:

Add I18N support

Location:
trunk
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/Makefile.PL

    r1435 r1546  
    1515requires 'Catalyst::Plugin::Session::State::Cookie' => '0'; 
    1616requires 'Catalyst::Plugin::Prototype' => '0'; 
     17requires 'Catalyst::Plugin::I18N' => '0'; 
    1718requires 'Catalyst::View::TT' => '0'; 
    1819requires 'LATMOS::Accounts' => '0'; 
     
    3233 
    3334sub postamble { 
     35    my @po = map { m:lib/LATMOS/Accounts/Web/I18N/([^\.]+)\.po$:; $1 } 
     36            glob('lib/LATMOS/Accounts/Web/I18N/*.po'); 
     37 
     38    my $makepo = join("\n\n", map { 
     39        " 
     40lib/LATMOS/Accounts/Web/I18N/$_.po: lib/LATMOS/Accounts/Web/I18N/messages.pot 
     41\t[ -f lib/LATMOS/Accounts/Web/I18N/$_.po ] || msginit --no-translator --input=lib/LATMOS/Accounts/Web/I18N/messages.pot --output= --locale=$_ 
     42\tmsgmerge -U lib/LATMOS/Accounts/Web/I18N/$_.po lib/LATMOS/Accounts/Web/I18N/messages.pot 
     43 
     44        " 
     45        } @po 
     46    ); 
     47 
     48    $makepo .= "\n\npo: " . join(' ', map { "lib/LATMOS/Accounts/Web/I18N/$_.po" } @po) . "\n"; 
     49 
    3450    <<EOF; 
    35 # .PHONY .= svnmanifest 
     51.PHONY: lib/LATMOS/Accounts/Web/I18N/messages.pot 
     52 
     53pot: lib/LATMOS/Accounts/Web/I18N/messages.pot 
     54 
     55lib/LATMOS/Accounts/Web/I18N/messages.pot: 
     56\tcat MANIFEST | egrep '^(lib|root/html)' | xargs xgettext.pl -o lib/LATMOS/Accounts/Web/I18N/messages.pot 
     57 
     58$makepo 
    3659 
    3760svnmanifest: 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web.pm

    r1534 r1546  
    2424    Prototype 
    2525    XMLRPC 
     26    I18N 
    2627    /; 
    2728 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Root.pm

    r1544 r1546  
    3131sub begin : Private { 
    3232    my ( $self, $c ) = @_; 
     33 
     34    my ($locale) = split(';', $c->req->header('Accept-Language') || ''); 
     35    if (my $plocale = ($c->req->param('locale')|| $c->session->{'locale'})) { 
     36        $c->session->{'locale'} = $locale = $plocale; 
     37    } 
     38    $c->languages($locale ? [ $locale ] : ''); 
    3339 
    3440    if ($c->user_exists) { 
  • trunk/LATMOS-Accounts-Web/root/html/includes/defs.tt

    r1162 r1546  
     1[% MACRO l(text, args) BLOCK; 
     2    c.localize(text, args); 
     3END; %] 
    14 
    25[% perm_denied = BLOCK %] 
  • trunk/LATMOS-Accounts-Web/root/html/includes/wrapper.tt

    r1485 r1546  
    4545 
    4646<h1 style=""> 
    47     Gestion informatique 
     47    [% l('IT management') %] 
    4848    [% IF c.config.company %] 
    4949    - [% c.config.company | html %] 
  • trunk/LATMOS-Accounts/MANIFEST

    r1520 r1546  
    103103lib/LATMOS/Accounts/Bases/Zimbra/User.pm 
    104104lib/LATMOS/Accounts/Cli.pm 
     105lib/LATMOS/Accounts/I18N/fr.po 
     106lib/LATMOS/Accounts/I18N/messages.pot 
    105107lib/LATMOS/Accounts/Log.pm 
    106108lib/LATMOS/Accounts/Mail.pm 
  • trunk/LATMOS-Accounts/Makefile.PL

    r1445 r1546  
    7373            DESTINSTALLMAN5DIR  => '$(DESTDIR)$(INSTALLMAN5DIR)', 
    7474            DESTINSTALLMAN8DIR  => '$(DESTDIR)$(INSTALLMAN8DIR)', 
     75            LOCALEDIR           => '/usr/share/locale', 
    7576            INST_MAN5DIR        => 'blib/man5', 
    7677            INST_MAN8DIR        => 'blib/man8', 
     
    9697 
    9798sub postamble { 
     99 
     100    my @po = map { m:lib/LATMOS/Accounts/I18N/([^\.]+)\.po$:; $1 } 
     101            glob('lib/LATMOS/Accounts/I18N/*.po'); 
     102 
     103    my $makepo = join("\n\n", map { 
     104        " 
     105lib/LATMOS/Accounts/I18N/$_.po: lib/LATMOS/Accounts/I18N/messages.pot 
     106\t[ -f lib/LATMOS/Accounts/I18N/$_.po ] || msginit --no-translator --input=lib/LATMOS/Accounts/I18N/messages.pot --output= --locale=$_ 
     107\tmsgmerge -U lib/LATMOS/Accounts/I18N/$_.po lib/LATMOS/Accounts/I18N/messages.pot 
     108 
     109        " 
     110        } @po 
     111    ); 
     112 
     113    $makepo .= "\n\npo: " . join(' ', map { "lib/LATMOS/Accounts/I18N/$_.po" } @po) . "\n"; 
     114 
    98115    <<EOF; 
    99116#.PHONY .= svnmanifest 
     117 
     118pot: lib/LATMOS/Accounts/I18N/messages.pot 
     119 
     120lib/LATMOS/Accounts/I18N/messages.pot: 
     121\tcat MANIFEST | egrep '^(lib|bin)' | xargs xgettext.pl -o lib/LATMOS/Accounts/I18N/messages.pot 
     122 
     123$makepo 
    100124 
    101125bin/la-sql-upgrade: bin/la-sql-upgrade.in 
     
    158182    my $section = $self->SUPER::install(); 
    159183 
    160     $section =~ s/(^install ::.*)/$1 install_config install_templates install_data/m; 
     184    $section =~ s/(^install ::.*)/$1 install_config install_templates install_data install_po/m; 
    161185    $section =~ s/\$\(INST_BIN\) \$\(DESTINSTALL(\w*)BIN\)/$& \$(INST_MAN5DIR) \$(DESTINSTALLMAN5DIR) \$(INST_MAN8DIR) \$(DESTINSTALLMAN8DIR)/g; 
    162186 
     
    179203        $(ABSPERLRUN) -MExtUtils::Install -e 'install({ sqldata => @ARGV })' \\ 
    180204            $(DESTDIR)$(DATADIR) 
     205 
     206install_po :: 
     207        install -d $(DESTDIR)$(LOCALEDIR)/LATMOS::Accounts 
     208        $(ABSPERLRUN) -MExtUtils::Install -e 'install({ "lib/LATMOS/Accounts/I18N" => @ARGV })' \\ 
     209        $(DESTDIR)$(LOCALEDIR)/LATMOS::Accounts 
    181210]; 
    182211   
  • trunk/LATMOS-Accounts/bin/la-query

    r1045 r1546  
    66use Getopt::Long; 
    77use Pod::Usage; 
     8use LATMOS::Accounts::I18N; 
    89 
    910=head1 NAME 
     
    115116my $LA = LATMOS::Accounts->new($config, noacl => 1); 
    116117my $labase = $LA->base($base); 
    117 $labase && $labase->load or die "Cannot load base"; 
     118$labase && $labase->load or die N("Cannot load base %s\n", $base); 
    118119 
    119120$labase->unexported($nounexp ? 0 : 1); 
  • trunk/LATMOS-Accounts/latmos-accounts.spec.in

    r1376 r1546  
    3535BuildRequires: perl(HTTP::Cookies) 
    3636BuildRequires: perl(XML::XPath) 
     37BuildRequires: perl(Locale::gettext) 
    3738 
    3839Requires: perl(Mail::Sendmail) 
     
    9899%perl_vendorlib/* 
    99100%_datadir/latmos-accounts 
     101%_datadir/locale/* 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm

    r1527 r1546  
    1010use LATMOS::Accounts::Log; 
    1111use LATMOS::Accounts::Acls; 
     12use LATMOS::Accounts::I18N; 
    1213 
    1314our $VERSION = '5.0.11'; 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm

    r1545 r1546  
    384384    my ($self, $otype, $id, %data) = @_; 
    385385    "$id" or do { 
    386         $self->log(LA_ERR, "Cannot create %s object with empty id", 
     386        $self->log(LA_ERR, _("Cannot create %s object with empty id"), 
    387387            $otype); 
    388388        return; 
Note: See TracChangeset for help on using the changeset viewer.