From e8e483d07943e7c4874ee6147e3910ee868ed14d Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 18:53:02 +0200 Subject: [PATCH] L10N is here ;-) --- .gitignore | 6 ++++ docs/createtranslation.pl | 28 ++++++++++++++++ l10n/l10n-de.php | 5 +++ lib/l10n.php | 17 ++++++---- log/l10n/de.php | 14 ++++++++ log/l10n/de.po | 68 +++++++++++++++++++++++++++++++++++++++ log/l10n/log | 3 ++ log/l10n/messages.pot | 66 +++++++++++++++++++++++++++++++++++++ log/l10n/xgettextfiles | 1 + log/templates/index.php | 26 +++++++-------- 10 files changed, 214 insertions(+), 20 deletions(-) create mode 100644 docs/createtranslation.pl create mode 100644 l10n/l10n-de.php create mode 100644 log/l10n/de.php create mode 100644 log/l10n/de.po create mode 100644 log/l10n/log create mode 100644 log/l10n/messages.pot create mode 100644 log/l10n/xgettextfiles diff --git a/.gitignore b/.gitignore index 9cfb7a5861e..6a1ffc21cae 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,11 @@ _darcs/* CVS/* .svn/* RCS/* + +# kdevelop .kdev *.kdev4 + +# Lokalize +*lokalize* + diff --git a/docs/createtranslation.pl b/docs/createtranslation.pl new file mode 100644 index 00000000000..4c1c7c38d73 --- /dev/null +++ b/docs/createtranslation.pl @@ -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 " 'd.m.Y', + 'datetime' => 'd.m.Y H:i:s', + 'time' => 'H:i:s' ); diff --git a/lib/l10n.php b/lib/l10n.php index e800941e3d3..4eae109cb52 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -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]; } diff --git a/log/l10n/de.php b/log/l10n/de.php new file mode 100644 index 00000000000..5cfc3486aff --- /dev/null +++ b/log/l10n/de.php @@ -0,0 +1,14 @@ + "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" +); diff --git a/log/l10n/de.po b/log/l10n/de.po new file mode 100644 index 00000000000..a901754f1a6 --- /dev/null +++ b/log/l10n/de.po @@ -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 , 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 \n" +"Language-Team: German \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" + + diff --git a/log/l10n/log b/log/l10n/log new file mode 100644 index 00000000000..e5e074bf9aa --- /dev/null +++ b/log/l10n/log @@ -0,0 +1,3 @@ +[General] +LangCode=de +TargetLangCode=de diff --git a/log/l10n/messages.pot b/log/l10n/messages.pot new file mode 100644 index 00000000000..2da2355a3ab --- /dev/null +++ b/log/l10n/messages.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 "" diff --git a/log/l10n/xgettextfiles b/log/l10n/xgettextfiles new file mode 100644 index 00000000000..a24bcc89a85 --- /dev/null +++ b/log/l10n/xgettextfiles @@ -0,0 +1 @@ +../templates/index.php diff --git a/log/templates/index.php b/log/templates/index.php index 5f398b1dbc6..2756332f519 100644 --- a/log/templates/index.php +++ b/log/templates/index.php @@ -1,19 +1,19 @@

- Filter : + t( 'Filter:' ); ?> - name="login" id="logins" /> - name="logout" id="logouts" /> - name="read" id="downloads" /> - name="write" id="uploads" /> - name="create" id="creations" /> - name="delete" id="deletions" /> + name="login" id="logins" /> + name="logout" id="logouts" /> + name="read" id="downloads" /> + name="write" id="uploads" /> + name="create" id="creations" /> + name="delete" id="deletions" />

- Show : -  entries per page. + t( 'Show:' ); ?> +  t( 'entries per page.' ); ?>

@@ -23,15 +23,15 @@ - - + + - + @@ -42,7 +42,7 @@

- Clear log entries before + t( 'Clear log entries before' ); ?> -- 2.39.5

WhatWhent( 'What' ); ?>t( 'When' ); ?>
"> l('datetime', $entry["date"] ); ?>