forked from thefuxia/Germanix-WordPress-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
germanix_translate.php
99 lines (88 loc) · 2.27 KB
/
germanix_translate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/*
Plugin Name: Germanix Translate
Plugin URI: http://toscho.de/
Description: Rüstet deutsche Übersetzungen im Backend nach.
Version: 0.1
Author: Thomas Scholz
Author URI: http://toscho.de
Created: 13.05.2010
Changelog
v 0.1
* Split from the original Germanix plugin
*/
if ( is_admin() || ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) )
{
add_filter('gettext',
array ( 'Germanix_Translate', 'gettext_filter' ), 10, 1);
add_filter('ngettext',
array ( 'Germanix_Translate', 'ngettext_filter' ), 10, 3);
add_filter('http_request_args',
array ( 'Germanix_Translate', 'no_upgrade_check' ), 5, 2);
}
class Germanix_Translate
{
/**
* Adds missing translations in gettext.
*
* @param string $str
* @return string
*/
static function gettext_filter($str)
{
return strtr($str, array (
// Extend to fit your needs.
'Dashboard' => 'Übersicht',
'Submitted on' => 'Eingereicht am',
'Biographische Angaben' => 'Beschreibung',
'- Wähle -' => 'Wähle',
'Theme Files' => 'Theme-Dateien',
'Attribute' => 'Eigenschaften',
'Template' => 'Vorlage',
'neues Fenster oder neuen Tab.'
=> 'neues Fenster oder neuer Tab.',
'aktuelle Fenster oder aktueller Tab, ohne Frames.'
=> 'aktuelles Fenster oder aktueller Tab, ohne Frames.',
));
}
/**
* Adds missing translations in ngettext.
*
* @param string $translation
* @param string $single
* @param string $plural
* @return string
*/
static function ngettext_filter($trans, $single, $plural)
{
return "Approved" == $plural ? "Genehmigte" : $trans;
}
/**
* Blocks update checks for this plugin.
*
* @author Mark Jaquith http://markjaquith.wordpress.com
* @link http://wp.me/p56-65
* @param array $r
* @param string $url
* @return array
*/
static function no_upgrade_check($r, $url)
{
if ( 0 !== strpos(
$url
, 'http://api.wordpress.org/plugins/update-check'
)
)
{ // Not a plugin update request. Bail immediately.
return $r;
}
$plugins = unserialize( $r['body']['plugins'] );
$p_base = plugin_basename( __FILE__ );
unset (
$plugins->plugins[$p_base],
$plugins->active[array_search($p_base, $plugins->active)]
);
$r['body']['plugins'] = serialize($plugins);
return $r;
}
}