L10N is here ;-)

This commit is contained in:
Jakob Sack 2011-06-19 18:53:02 +02:00
parent abac11d8c4
commit e8e483d079
10 changed files with 214 additions and 20 deletions

6
.gitignore vendored
View File

@ -16,5 +16,11 @@ _darcs/*
CVS/*
.svn/*
RCS/*
# kdevelop
.kdev
*.kdev4
# Lokalize
*lokalize*

28
docs/createtranslation.pl Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/perl
use strict;
use Locale::PO;
use Data::Dumper;
opendir( DIR, '.' );
my @files = readdir( DIR );
closedir( DIR );
foreach my $i ( @files ){
next unless $i =~ m/^(.*)\.po$/;
my $lang = $1;
my $hash = Locale::PO->load_file_ashash( $i );
# Create array
my @strings = ();
foreach my $key ( keys( %{$hash} )){
next if $key eq '""';
push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr());
}
# Write PHP file
open( OUT, ">$lang.php" );
print OUT "<?php \$TRANSLATIONS = array(\n";
print OUT join( ",\n", @strings );
print OUT "\n);\n";
close( OUT );
}

5
l10n/l10n-de.php Normal file
View File

@ -0,0 +1,5 @@
<?php
$LOCALIZATIONS = array(
'date' => 'd.m.Y',
'datetime' => 'd.m.Y H:i:s',
'time' => 'H:i:s' );

View File

@ -57,32 +57,33 @@ class OC_L10N{
* language.
*/
public function __construct( $app, $lang = null ){
global $SERVERROOT;
// Find the right language
if( is_null( $lang )){
self::findLanguage( $app );
$lang = self::findLanguage( $app );
}
// Use cache if possible
if(array_key_exists($app.'::'.$lang, self::$cache )){
$this->translations = self::$cache[$app.'::'.$lang]['t'];
$this->localizations = self::$cache[$app.'::'.$lang]['l'];
}
else{
$i18ndir = self::findI18nDir( $app );
// Localization is in /l10n, Texts are in $i18ndir
// (Just no need to define date/time format etc. twice)
if( file_exists( $i18ndir.$lang.'php' )){
if( file_exists( $i18ndir.$lang.'.php' )){
// Include the file, save the data from $CONFIG
include( $i18ndir.$lang.'php' );
include( $i18ndir.$lang.'.php' );
if( isset( $TRANSLATIONS ) && is_array( $TRANSLATIONS )){
$this->translations = $TRANSLATIONS;
}
}
if( file_exists( '/l10n/l10n-'.$lang.'php' )){
if( file_exists( $SERVERROOT.'/l10n/l10n-'.$lang.'.php' )){
// Include the file, save the data from $CONFIG
include( $SERVERROOT.'/l10n/l10n-'.$lang.'php' );
include( $SERVERROOT.'/l10n/l10n-'.$lang.'.php' );
if( isset( $LOCALIZATIONS ) && is_array( $LOCALIZATIONS )){
$this->localizations = array_merge( $this->localizations, $LOCALIZATIONS );
}
@ -133,12 +134,15 @@ class OC_L10N{
public function l($type, $data){
switch($type){
case 'date':
if( is_string( $data )) $data = strtotime( $data );
return date( $this->localizations['date'], $data );
break;
case 'datetime':
if( is_string( $data )) $data = strtotime( $data );
return date( $this->localizations['datetime'], $data );
break;
case 'time':
if( is_string( $data )) $data = strtotime( $data );
return date( $this->localizations['time'], $data );
break;
default:
@ -209,7 +213,6 @@ class OC_L10N{
$accepted_languages = preg_split( '/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
foreach( $accepted_languages as $i ){
$temp = explode( ';', $i );
$temp = explode( '-', $temp[0] );
if( array_key_exists( $temp[0], $available )){
return $temp[0];
}

14
log/l10n/de.php Normal file
View File

@ -0,0 +1,14 @@
<?php $TRANSLATIONS = array(
"Show:" => "Zeige",
"Uploads" => "Uploads",
"Filter:" => "Filter:",
"Logouts" => "Abmeldungen",
"Logins" => "Anmeldungen",
"When" => "Wann",
"Downloads" => "Downloads",
"Clear log entries before" => "Lösche Einträge vor dem",
"What" => "Was",
"entries per page." => "Einträge pro Seite",
"Creations" => "Erstellungen",
"Deletions" => "Löschungen"
);

68
log/l10n/de.po Normal file
View File

@ -0,0 +1,68 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Jakob Sack <mail@jakobsack.de>, 2011.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-19 16:44+0200\n"
"PO-Revision-Date: 2011-06-19 16:54+0200\n"
"Last-Translator: Jakob Sack <mail@jakobsack.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Lokalize 1.2\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#: ../templates/index.php:4
msgid "Filter:"
msgstr "Filter:"
#: ../templates/index.php:7
msgid "Logins"
msgstr "Anmeldungen"
#: ../templates/index.php:8
msgid "Logouts"
msgstr "Abmeldungen"
#: ../templates/index.php:9
msgid "Downloads"
msgstr "Downloads"
#: ../templates/index.php:10
msgid "Uploads"
msgstr "Uploads"
#: ../templates/index.php:11
msgid "Creations"
msgstr "Erstellungen"
#: ../templates/index.php:12
msgid "Deletions"
msgstr "Löschungen"
#: ../templates/index.php:15
msgid "Show:"
msgstr "Zeige"
#: ../templates/index.php:16
msgid "entries per page."
msgstr "Einträge pro Seite"
#: ../templates/index.php:26
msgid "What"
msgstr "Was"
#: ../templates/index.php:27
msgid "When"
msgstr "Wann"
#: ../templates/index.php:45
msgid "Clear log entries before"
msgstr "Lösche Einträge vor dem"

3
log/l10n/log Normal file
View File

@ -0,0 +1,3 @@
[General]
LangCode=de
TargetLangCode=de

66
log/l10n/messages.pot Normal file
View File

@ -0,0 +1,66 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-19 16:53+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../templates/index.php:4
msgid "Filter:"
msgstr ""
#: ../templates/index.php:7
msgid "Logins"
msgstr ""
#: ../templates/index.php:8
msgid "Logouts"
msgstr ""
#: ../templates/index.php:9
msgid "Downloads"
msgstr ""
#: ../templates/index.php:10
msgid "Uploads"
msgstr ""
#: ../templates/index.php:11
msgid "Creations"
msgstr ""
#: ../templates/index.php:12
msgid "Deletions"
msgstr ""
#: ../templates/index.php:15
msgid "Show:"
msgstr ""
#: ../templates/index.php:16
msgid "entries per page."
msgstr ""
#: ../templates/index.php:26
msgid "What"
msgstr ""
#: ../templates/index.php:27
msgid "When"
msgstr ""
#: ../templates/index.php:45
msgid "Clear log entries before"
msgstr ""

1
log/l10n/xgettextfiles Normal file
View File

@ -0,0 +1 @@
../templates/index.php

View File

@ -1,19 +1,19 @@
<div class="controls">
<form id="logs_options" method='post'>
<p>
<span>Filter :</span>
<span><?php echo $l->t( 'Filter:' ); ?></span>
<input type="checkbox" checked="" name="all" id="all" /> <label for="all">All</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['login']?> name="login" id="logins" /> <label for="logins">Logins</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['logout']?> name="logout" id="logouts" /> <label for="logouts">Logouts</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['read']?> name="read" id="downloads" /> <label for="downloads">Downloads</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['write']?> name="write" id="uploads" /> <label for="uploads">Uploads</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['create']?> name="create" id="creations" /> <label for="creations">Creations</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['delete']?> name="delete" id="deletions" /> <label for="deletions">Deletions</label>
<input type="checkbox" class='action' <?php echo $_['showActions']['login']?> name="login" id="logins" /> <label for="logins"><?php echo $l->t( 'Logins' ); ?></label>
<input type="checkbox" class='action' <?php echo $_['showActions']['logout']?> name="logout" id="logouts" /> <label for="logouts"><?php echo $l->t( 'Logouts' ); ?></label>
<input type="checkbox" class='action' <?php echo $_['showActions']['read']?> name="read" id="downloads" /> <label for="downloads"><?php echo $l->t( 'Downloads' ); ?></label>
<input type="checkbox" class='action' <?php echo $_['showActions']['write']?> name="write" id="uploads" /> <label for="uploads"><?php echo $l->t( 'Uploads' ); ?></label>
<input type="checkbox" class='action' <?php echo $_['showActions']['create']?> name="create" id="creations" /> <label for="creations"><?php echo $l->t( 'Creations' ); ?></label>
<input type="checkbox" class='action' <?php echo $_['showActions']['delete']?> name="delete" id="deletions" /> <label for="deletions"><?php echo $l->t( 'Deletions' ); ?></label>
</p>
<p>
<span>Show :</span>
<input type="text" maxlength="3" size="3" value="<?php echo $_['size']?>" name='size'/>&nbsp;entries per page.
<span><?php echo $l->t( 'Show:' ); ?></span>
<input type="text" maxlength="3" size="3" value="<?php echo $_['size']?>" name='size'/>&nbsp;<?php echo $l->t( 'entries per page.' ); ?>
<input class="prettybutton" type="submit" name="save" value="Save" />
</p>
@ -23,15 +23,15 @@
<table cellspacing="0">
<thead>
<tr>
<th>What</th>
<th>When</th>
<th><?php echo $l->t( 'What' ); ?></th>
<th><?php echo $l->t( 'When' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach($_["logs"] as $entry): ?>
<tr>
<td class="<?php echo $entry["action"]; ?>"><em><?php echo $entry["action"]; ?> <?php echo $entry["user"]; ?></em> <?php echo $entry["info"]; ?></td>
<td class="date"><?php echo $entry["date"]; ?></td>
<td class="date"><?php echo $l->l('datetime', $entry["date"] ); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
@ -42,7 +42,7 @@
<div class="controls">
<form id="logs_options" method='post'>
<p>
<span>Clear log entries before </span>
<span><?php echo $l->t( 'Clear log entries before' ); ?> </span>
<input type="date" id="removeBeforeDate" name="removeBeforeDate"/>
<input class="prettybutton nofloat" type="submit" name="clear" value="Clear" />
<input class="prettybutton" type="submit" name="clearall" value="Clear All" />