@@ -16,6 +16,7 @@ class InertiaTable
1616 private Collection $ search ;
1717 private Collection $ filters ;
1818 private bool $ globalSearch = true ;
19+ private array $ translations ;
1920
2021 public function __construct (Request $ request )
2122 {
@@ -25,6 +26,7 @@ public function __construct(Request $request)
2526 $ this ->sortables = [];
2627 $ this ->search = new Collection ;
2728 $ this ->filters = new Collection ;
29+ $ this ->translations = $ this ->getDefaultTranlsations ();
2830 }
2931
3032 /**
@@ -57,6 +59,7 @@ public function getQueryBuilderProps(): array
5759 'columns ' => $ columns ->isNotEmpty () ? $ columns ->all () : (object ) [],
5860 'search ' => $ search ->isNotEmpty () ? $ search ->all () : (object ) [],
5961 'filters ' => $ filters ->isNotEmpty () ? $ filters ->all () : (object ) [],
62+ 'translations ' => $ this ->translations ,
6063 ];
6164 }
6265
@@ -202,6 +205,19 @@ public function addColumns(array $columns = []): self
202205 return $ this ;
203206 }
204207
208+ /**
209+ * Add and update translations array
210+ *
211+ * @param array $updatedTranslations
212+ * @return self
213+ */
214+ public function updateTranslations (array $ updatedTranslations = []): self
215+ {
216+ $ this ->translations = array_merge ($ this ->translations , $ updatedTranslations );
217+
218+ return $ this ;
219+ }
220+
205221 /**
206222 * Add a search row to the query builder.
207223 *
@@ -248,4 +264,22 @@ public function addFilter(string $key, string $label, array $options): self
248264
249265 return $ this ;
250266 }
267+
268+ private function getDefaultTranlsations (): array
269+ {
270+ $ translationsArray = __ ('pagination ' );
271+
272+ $ translationsArray = array_merge ($ translationsArray , [
273+ 'filter ' => "Filter " ,
274+ "next " => "suivant " ,
275+ "no_results_found " => "Aucun résultats " ,
276+ "of " => "sur " ,
277+ "previous " => "précédent " ,
278+ "results " => "résultats " ,
279+ "search_placeholder " => "Chercher " ,
280+ "to " => "à " ,
281+ ]);
282+
283+ return $ translationsArray ;
284+ }
251285}
0 commit comments