@@ -47,6 +47,7 @@ public function getFunctions()
4747 return json_encode ([
4848 'name ' => $ dataTable ->getName (),
4949 'method ' => $ dataTable ->getMethod (),
50+ 'language ' => $ this ->getLanguageSettings ($ dataTable ),
5051 ]);
5152 }, ['is_safe ' => ['html ' ]]),
5253 ];
@@ -91,10 +92,22 @@ function (AbstractColumn $column) {
9192 ];
9293 }, $ datatable ->getColumns ());
9394
94- if ($ datatable ->getSetting ('language_from_cdn ' ) && array_key_exists ($ locale , $ this ->languageCDNFile )) {
95- $ result ['language ' ] = ['url ' => "//cdn.datatables.net/plug-ins/1.10.15/i18n/ {$ this ->languageCDNFile [$ locale ]}" ];
95+ $ result ['language ' ] = $ this ->getLanguageSettings ($ datatable );
96+
97+ return $ result ;
98+ }
99+
100+ /**
101+ * @param DataTable $dataTable
102+ * @return array
103+ */
104+ private function getLanguageSettings (DataTable $ dataTable )
105+ {
106+ $ locale = $ this ->translator ->getLocale ();
107+ if ($ dataTable ->getSetting ('language_from_cdn ' ) && array_key_exists ($ locale , $ this ->languageCDNFile )) {
108+ return ['url ' => "//cdn.datatables.net/plug-ins/1.10.15/i18n/ {$ this ->languageCDNFile [$ locale ]}" ];
96109 } else {
97- $ result [ ' language ' ] = [
110+ return [
98111 'processing ' => $ this ->translator ->trans ('datatable.datatable.processing ' ),
99112 'search ' => $ this ->translator ->trans ('datatable.datatable.search ' ),
100113 'lengthMenu ' => $ this ->translator ->trans ('datatable.datatable.lengthMenu ' ),
@@ -115,10 +128,9 @@ function (AbstractColumn $column) {
115128 'aria ' => [
116129 'sortAscending ' => $ this ->translator ->trans ('datatable.datatable.aria.sortAscending ' ),
117130 'sortDescending ' => $ this ->translator ->trans ('datatable.datatable.aria.sortDescending ' ),
118- ], ];
131+ ],
132+ ];
119133 }
120-
121- return $ result ;
122134 }
123135
124136 /**
0 commit comments