summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-11-09 13:55:17 +0100
committeremkael <emkael@tlen.pl>2018-11-09 13:55:17 +0100
commitf50e56a49e6a49f69e34c74b3c44d25347b27cff (patch)
tree72c1ed831c840e67722a894aea1e6feecfc39cc7
parentcfba80260caf8b62515088b2f7bb763c1ace3c14 (diff)
Translation support
-rw-r--r--tdd/tdd-bootstrap.php10
-rw-r--r--tdd/translations.json4
2 files changed, 13 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('&nbsp;', '', $nextTr->find('td', 5)->innertext));
$deal = $this->deals_by_tables[$table];
- $insert = "<a href=\"#table-$table\"><h4 id=\"table-$table\">Stół $table &ndash; Rozdanie {$deal->deal_num}</h4></a>";
+ $insert = "<a href=\"#table-$table\"><h4 id=\"table-$table\">" . $this->__("Stół") . " $table" . " &ndash; " . $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)
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"
+}