PluginProbe
Tracking Code Manager / 1.11.8
Tracking Code Manager v1.11.8
2.8.0 2.7.0 trunk 1.11.8 1.11.9 1.12.0 1.12.1 1.12.2 1.12.3 1.4 1.5 2.0.0 2.0.1 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.2.0 All 29 releases
← All changes | includes/classes/utils/Language.php +112 -115 trunk1.11.8 View file →
@@ -1,115 +1,112 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - exit;
4 -}
5 -
6 -class TCMP_Language {
7 - var $domain;
8 - var $bundle;
9 -
10 - function __construct() {
11 - $this->bundle = new TCMP_Properties();
12 - }
13 - function load( $domain, $file ) {
14 - $this->domain = $domain;
15 - $this->bundle->load( $file );
16 - }
17 - //echo the $ec->lang->L result
18 - function P( $key, $v1 = null, $v2 = null, $v3 = null, $v4 = null, $v5 = null ) {
19 - $what = $this->L( $key, $v1, $v2, $v3, $v4, $v5 );
20 - global $tcmp_allowed_html_tags;
21 - echo wp_kses( $what, $tcmp_allowed_html_tags );
22 - }
23 - //verify if the key is defined or not
24 - function H( $key ) {
25 - if ( null == $this->bundle || ! $this->bundle->hasKeys() ) {
26 - return false;
27 - }
28 -
29 - $result = false;
30 - if ( $this->bundle->existsKey( $key ) ) {
31 - $result = true;
32 - } elseif ( $this->bundle->existsKey( $key . '1' ) ) {
33 - $result = true;
34 - } else {
35 - //special way to call this function passing arguments
36 - //WTF_something means key=WTF and something as first argument
37 - $s = strpos( $result, '_' );
38 - if ( false !== $s ) {
39 - $text = substr( $result, 0, $s );
40 - $value = substr( $result, $s + 1 );
41 - $e = strrpos( $value, '_' );
42 - if ( false !== $e ) {
43 - $text .= substr( $value, $e + 1 );
44 - $value = substr( $value, 0, $e );
45 - }
46 - if ( $this->bundle->existsKey( $text ) ) {
47 - $result = true;
48 - }
49 - }
50 - }
51 - return $result;
52 - }
53 - //read the key from a text file with its translation. Try to translate using __(
54 - function L( $key, $v1 = null, $v2 = null, $v3 = null, $v4 = null, $v5 = null ) {
55 - global $tcmp;
56 - $result = $key;
57 - $args = array( $v1, $v2, $v3, $v4, $v5 );
58 -
59 - if ( null == $this->bundle || ! $this->bundle->hasKeys() ) {
60 - $result = __( $result, $this->domain );
61 - } else {
62 - //i use the file to store the translations without writing it inside the code
63 - if ( $this->bundle->existsKey( $key ) ) {
64 - $result = $this->bundle->getString( $key );
65 - $result = __( $result, $this->domain );
66 - } elseif ( $this->bundle->existsKey( $key . '1' ) ) {
67 - $result = '';
68 - $n = 1;
69 - while ( $this->bundle->existsKey( $key . $n ) ) {
70 - if ( '' != $result ) {
71 - $result .= '<br/>';
72 - }
73 - $result .= __( $this->bundle->getString( $key . $n ), $this->domain );
74 - ++$n;
75 - }
76 - } else {
77 - //special way to call this function passing arguments
78 - //WTF_something means key=WTF and something as first argument
79 - $s = strpos( $result, '_' );
80 - if ( false !== $s ) {
81 - $text = substr( $result, 0, $s );
82 - $value = substr( $result, $s + 1 );
83 - $e = strrpos( $value, '_' );
84 - if ( false !== $e ) {
85 - $text .= substr( $value, $e + 1 );
86 - $value = substr( $value, 0, $e );
87 - }
88 - if ( $this->bundle->existsKey( $text ) ) {
89 - $result = $this->bundle->getString( $text );
90 - $args = array( $value );
91 - }
92 - }
93 - $result = __( $result, $this->domain );
94 - }
95 - }
96 - if ( $result == $key ) {
97 - $this->bundle->pushString( $key, '' );
98 - }
99 - //here i translate it using WP
100 - foreach ( $args as $k => $v ) {
101 - $k = '{' . $k . '}';
102 - while ( strpos( $result, $k ) !== false ) {
103 - $result = str_replace( $k, $v, $result );
104 - }
105 - }
106 - foreach ( $args as $k => $v ) {
107 - $k = '{dt:' . $k . '}';
108 - $v = $tcmp->utils->formatSmartDatetime( $v );
109 - while ( strpos( $result, $k ) !== false ) {
110 - $result = str_replace( $k, $v, $result );
111 - }
112 - }
113 - return $result;
114 - }
115 -}
1 +<?php
2 +if (!defined('ABSPATH')) exit;
3 +
4 +class TCMP_Language {
5 + var $domain;
6 + var $bundle;
7 +
8 + function __construct() {
9 + $this->bundle=new TCMP_Properties();
10 + }
11 + function load($domain, $file) {
12 + $this->domain=$domain;
13 + $this->bundle->load($file);
14 + }
15 + //echo the $ec->Lang->L result
16 + function P($key, $v1=NULL, $v2=NULL, $v3=NULL, $v4=NULL, $v5=NULL) {
17 + $what=$this->L($key, $v1, $v2, $v3, $v4, $v5);
18 + echo $what;
19 + }
20 + //verify if the key is defined or not
21 + function H($key) {
22 + if($this->bundle==NULL || !$this->bundle->hasKeys()) {
23 + return FALSE;
24 + }
25 +
26 + $result=FALSE;
27 + if($this->bundle->existsKey($key)) {
28 + $result=TRUE;
29 + } elseif($this->bundle->existsKey($key.'1')) {
30 + $result=TRUE;
31 + } else {
32 + //special way to call this function passing arguments
33 + //WTF_something means key=WTF and something as first argument
34 + $s=strpos($result, '_');
35 + if ($s!==FALSE) {
36 + $text=substr($result, 0, $s);
37 + $value=substr($result, $s + 1);
38 + $e=strrpos($value, '_');
39 + if ($e!==FALSE) {
40 + $text.=substr($value, $e + 1);
41 + $value=substr($value, 0, $e);
42 + }
43 + if ($this->bundle->existsKey($text)) {
44 + $result=TRUE;
45 + }
46 + }
47 + }
48 + return $result;
49 + }
50 + //read the key from a text file with its translation. Try to translate using __(
51 + function L($key, $v1=NULL, $v2=NULL, $v3=NULL, $v4=NULL, $v5=NULL) {
52 + global $tcmp;
53 + $result=$key;
54 + $args=array($v1, $v2, $v3, $v4, $v5);
55 +
56 + if($this->bundle==NULL || !$this->bundle->hasKeys()) {
57 + $result=__($result, $this->domain);
58 + } else {
59 + //i use the file to store the translations without writing it inside the code
60 + if ($this->bundle->existsKey($key)) {
61 + $result=$this->bundle->getString($key);
62 + $result=__($result, $this->domain);
63 + } elseif ($this->bundle->existsKey($key.'1')) {
64 + $result='';
65 + $n=1;
66 + while ($this->bundle->existsKey($key.$n)) {
67 + if ($result != '') {
68 + $result .= '<br/>';
69 + }
70 + $result .= __($this->bundle->getString($key . $n), $this->domain);
71 + ++$n;
72 + }
73 + } else {
74 + //special way to call this function passing arguments
75 + //WTF_something means key=WTF and something as first argument
76 + $s=strpos($result, '_');
77 + if ($s!==FALSE) {
78 + $text=substr($result, 0, $s);
79 + $value=substr($result, $s + 1);
80 + $e=strrpos($value, '_');
81 + if ($e!==FALSE) {
82 + $text .= substr($value, $e + 1);
83 + $value=substr($value, 0, $e);
84 + }
85 + if ($this->bundle->existsKey($text)) {
86 + $result=$this->bundle->getString($text);
87 + $args=array($value);
88 + }
89 + }
90 + $result=__($result, $this->domain);
91 + }
92 + }
93 + if($result==$key) {
94 + $this->bundle->pushString($key, '');
95 + }
96 + //here i translate it using WP
97 + foreach($args as $k=>$v) {
98 + $k='{'.$k.'}';
99 + while(strpos($result, $k)!==FALSE) {
100 + $result=str_replace($k, $v, $result);
101 + }
102 + }
103 + foreach($args as $k=>$v) {
104 + $k='{dt:'.$k.'}';
105 + $v=$tcmp->Utils->formatSmartDatetime($v);
106 + while(strpos($result, $k)!==FALSE) {
107 + $result=str_replace($k, $v, $result);
108 + }
109 + }
110 + return $result;
111 + }
112 +}