From 5ca1be26b4c44d8991bc0a39bc7fa9fd4c41e3c0 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 9 Nov 2018 14:01:18 +0100 Subject: Making translations public for other classes --- tdd/tdd-bootstrap.php | 14 +++++++++----- tdd/tdd-handrecord-tpl.php | 6 +++--- tdd/translations.json | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tdd/tdd-bootstrap.php b/tdd/tdd-bootstrap.php index 0db3fa1..c4249c9 100644 --- a/tdd/tdd-bootstrap.php +++ b/tdd/tdd-bootstrap.php @@ -4,20 +4,24 @@ require_once('tdd-simple-html-dom.php'); class Protocol { + private static $translations = array(); + function __construct($prefix, $round, $board) { $this->prefix = $prefix; $this->round = $round; $this->board = $board; - $this->translations = json_decode(file_get_contents('translations.json'), TRUE); + if (file_exists('translations.json')) { + static::$translations = json_decode(file_get_contents('translations.json'), TRUE); + } $this->deals_by_tables = array(); if(!file_exists($this->get_filename())) { throw new Exception('file not found: ' . $this->get_filename()); } } - function __($string) { - if (isset($this->translations[$string])) { - return $this->translations[$string]; + static function __($string) { + if (isset(static::$translations[$string])) { + return static::$translations[$string]; } return $string; } @@ -51,7 +55,7 @@ class Protocol { $score2 = trim(str_replace(' ', '', $nextTr->find('td', 5)->innertext)); $deal = $this->deals_by_tables[$table]; - $insert = "

" . $this->__("Stół") . " $table" . " – " . $this->__("Rozdanie") . " {$deal->deal_num}

"; + $insert = "

" . static::__("Stół") . " $table" . " – " . static::__("Rozdanie") . " {$deal->deal_num}

"; // if is played on both tables of a match // note that the contract field for arbitral scores starts with 'A' (e.g. 'ARB' or 'AAA') if(($score1 !== '' || strpos($contract1, 'A') === 0) diff --git a/tdd/tdd-handrecord-tpl.php b/tdd/tdd-handrecord-tpl.php index 65836cf..da2335a 100644 --- a/tdd/tdd-handrecord-tpl.php +++ b/tdd/tdd-handrecord-tpl.php @@ -11,7 +11,7 @@ format_hand(3); ?> - <?php echo $this->dealer.'/'.$this->vuln; ?> format_hand(1); ?> @@ -22,7 +22,7 @@ ability): ?> - Maksymalna liczba lew: + : @@ -50,7 +50,7 @@ format_ability(3); ?>
 
- Minimax: format_minimax(); ?> + : format_minimax(); ?> diff --git a/tdd/translations.json b/tdd/translations.json index e7387aa..9761aeb 100644 --- a/tdd/translations.json +++ b/tdd/translations.json @@ -1,4 +1,5 @@ { "Stół": "Table", - "Rozdanie": "Board" + "Rozdanie": "Board", + "Maksymalna liczba lew": "Makeable tricks" } -- cgit v1.2.3