diff options
author | emkael <emkael@tlen.pl> | 2018-11-09 13:55:17 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-11-09 13:55:17 +0100 |
commit | f50e56a49e6a49f69e34c74b3c44d25347b27cff (patch) | |
tree | 72c1ed831c840e67722a894aea1e6feecfc39cc7 /tdd/tdd-bootstrap.php | |
parent | cfba80260caf8b62515088b2f7bb763c1ace3c14 (diff) |
Translation support
Diffstat (limited to 'tdd/tdd-bootstrap.php')
-rw-r--r-- | tdd/tdd-bootstrap.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tdd/tdd-bootstrap.php b/tdd/tdd-bootstrap.php index de78192..0db3fa1 100644 --- a/tdd/tdd-bootstrap.php +++ b/tdd/tdd-bootstrap.php @@ -8,12 +8,20 @@ class Protocol { $this->prefix = $prefix; $this->round = $round; $this->board = $board; + $this->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]; + } + return $string; + } + function get_filename() { return '..' . DIRECTORY_SEPARATOR . $this->prefix . $this->round . 'b-' . $this->board . '.html'; } @@ -43,7 +51,7 @@ class Protocol { $score2 = trim(str_replace(' ', '', $nextTr->find('td', 5)->innertext)); $deal = $this->deals_by_tables[$table]; - $insert = "<a href=\"#table-$table\"><h4 id=\"table-$table\">Stół $table – Rozdanie {$deal->deal_num}</h4></a>"; + $insert = "<a href=\"#table-$table\"><h4 id=\"table-$table\">" . $this->__("Stół") . " $table" . " – " . $this->__("Rozdanie") . " {$deal->deal_num}</h4></a>"; // 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) |