@@ -18,28 +18,63 @@ class DefaultTranslator implements ITranslator
1818 use SmartObject;
1919
2020
21+ const LANG_EN = 'en ' ;
22+ const LANG_CS = 'cs ' ;
23+
2124 const TRANSLATIONS = [
22- 'nextras.datagrid.filter.submit ' => 'Filter ' ,
23- 'nextras.datagrid.filter.cancel ' => 'Cancel ' ,
25+ self ::LANG_EN => [
26+ 'nextras.datagrid.filter.submit ' => 'Filter ' ,
27+ 'nextras.datagrid.filter.cancel ' => 'Cancel ' ,
28+
29+ 'nextras.datagrid.edit.label ' => 'Edit ' ,
30+ 'nextras.datagrid.edit.save ' => 'Save ' ,
31+ 'nextras.datagrid.edit.cancel ' => 'Cancel ' ,
32+
33+ 'nextras.datagrid.action.label ' => 'Action ' ,
34+ 'nextras.datagrid.action.prompt ' => '- select action - ' ,
35+ 'nextras.datagrid.action.process ' => 'Do ' ,
2436
25- 'nextras.datagrid.edit.label ' => 'Edit ' ,
26- 'nextras.datagrid.edit.save ' => 'Save ' ,
27- 'nextras.datagrid.edit.cancel ' => 'Cancel ' ,
37+ 'nextras.datagrid.pagination.first ' => 'First ' ,
38+ 'nextras.datagrid.pagination.previous ' => 'Previous ' ,
39+ 'nextras.datagrid.pagination.next ' => 'Next ' ,
40+ 'nextras.datagrid.pagination.last ' => 'Last ' ,
41+ ],
42+ self ::LANG_CS => [
43+ 'nextras.datagrid.filter.submit ' => 'Filtrovat ' ,
44+ 'nextras.datagrid.filter.cancel ' => 'Zrušit ' ,
2845
29- 'nextras.datagrid.action .label ' => 'Action ' ,
30- 'nextras.datagrid.action.prompt ' => '- select action - ' ,
31- 'nextras.datagrid.action.process ' => 'Do ' ,
46+ 'nextras.datagrid.edit .label ' => 'Upravit ' ,
47+ 'nextras.datagrid.edit.save ' => 'Uložit ' ,
48+ 'nextras.datagrid.edit.cancel ' => 'Zrušit ' ,
3249
33- 'nextras.datagrid.pagination.first ' => 'First ' ,
34- 'nextras.datagrid.pagination.previous ' => 'Previous ' ,
35- 'nextras.datagrid.pagination.next ' => 'Next ' ,
36- 'nextras.datagrid.pagination.last ' => 'Last ' ,
50+ 'nextras.datagrid.action.label ' => 'Akce ' ,
51+ 'nextras.datagrid.action.prompt ' => '- zvolte akci - ' ,
52+ 'nextras.datagrid.action.process ' => 'OK ' ,
53+
54+ 'nextras.datagrid.pagination.first ' => 'První ' ,
55+ 'nextras.datagrid.pagination.previous ' => 'Poslední ' ,
56+ 'nextras.datagrid.pagination.next ' => 'Další ' ,
57+ 'nextras.datagrid.pagination.last ' => 'Předchozí ' ,
58+ ],
3759 ];
3860
3961
62+ /** @var string */
63+ private $ language ;
64+
65+
66+ public function __construct ($ language )
67+ {
68+ if (!isset (self ::TRANSLATIONS [$ language ])) {
69+ throw new InvalidArgumentException ("Unsupported language ' $ language' " );
70+ }
71+ $ this ->language = $ language ;
72+ }
73+
74+
4075 public function translate ($ message , $ count = NULL )
4176 {
42- return isset (self ::TRANSLATIONS [$ message ]) ? self ::TRANSLATIONS [$ message ] : $ message ;
77+ return isset (self ::TRANSLATIONS [$ this -> language ][ $ message ]) ? self ::TRANSLATIONS [ $ this -> language ] [$ message ] : $ message ;
4378 }
4479
4580}
0 commit comments