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 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tdd/tdd-bootstrap.php') 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) -- cgit v1.2.3