From f50e56a49e6a49f69e34c74b3c44d25347b27cff Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 9 Nov 2018 13:55:17 +0100 Subject: Translation support --- tdd/tdd-bootstrap.php | 10 +++++++++- tdd/translations.json | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tdd/translations.json 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 = "

Stół $table – Rozdanie {$deal->deal_num}

"; + $insert = "

" . $this->__("Stół") . " $table" . " – " . $this->__("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/translations.json b/tdd/translations.json new file mode 100644 index 0000000..e7387aa --- /dev/null +++ b/tdd/translations.json @@ -0,0 +1,4 @@ +{ + "Stół": "Table", + "Rozdanie": "Board" +} -- cgit v1.2.3