Skip to content

Commit c6614d5

Browse files
committed
Added language to publishable translation file
1 parent 362cd33 commit c6614d5

13 files changed

+29
-82
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
2020
- Updated Livewire to 1.3
2121
- $disableSearchOnLoading default to false
2222
- Trim the search term when processing
23+
- Added language to publishable translation file
2324

2425
### Removed
2526

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,8 @@ You can override any of these in your table component:
164164
| $searchDebounce | 350 | Amount of time in ms to wait to send the search query and refresh the table |
165165
| $disableSearchOnLoading | false | Whether or not to disable the search bar when it is searching/loading new data |
166166
| $search | *none* | The initial search string |
167-
| $searchLabel | Search... | The placeholder for the search box |
168-
| $noResultsMessage | There are no results to display for this query. | The message to display when there are no results |
169167
| $clearSearchButton | false | Adds a clear button to the search input |
170168
| $clearSearchButtonClass | btn btn-outline-dark | The class applied to the clear button |
171-
| $clearSearchButtonLabel | Search | The label of the search button |
172169

173170
#### Sorting
174171

@@ -185,21 +182,18 @@ You can override any of these in your table component:
185182
| $perPageEnabled | true | Displays per page |
186183
| $perPageOptions | [10, 25, 50] | The options to limit the amount of results per page |
187184
| $perPage | 25 | Amount of items to show per page |
188-
| $perPageLabel | Per Page | The label for the per page filter |
189185

190186
#### Loading
191187

192188
| Property | Default | Usage |
193189
| -------- | ------- | ----- |
194190
| $loadingIndicator | false | Whether or not to show a loading indicator when searching |
195-
| $loadingMessage | Loading... | The loading message that gets displayed |
196191

197192
#### Offline
198193

199194
| Property | Default | Usage |
200195
| -------- | ------- | ----- |
201196
| $offlineIndicator | true | Whether or not to display an offline message when there is no connection |
202-
| $offlineMessage | You are not currently connected to the internet. | The message to display when offline |
203197

204198
#### Checkboxes
205199

resources/lang/en/strings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return [
4+
'clear' => 'Clear',
5+
'loading' => 'Loading...',
6+
'no_results' => 'There are no results to display for this query.',
7+
'offline' => 'You are not currently connected to the internet.',
8+
'per_page' => 'Per Page',
9+
'results' => 'Showing :first to :last out of :total results',
10+
'search' => 'Search...',
11+
];

resources/views/includes/_body.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
@if ($loadingIndicator)
22
<tbody wire:loading>
3-
<tr><td colspan="{{ collect($columns)->count() }}">{{ $loadingMessage }}</td></tr>
3+
<tr><td colspan="{{ collect($columns)->count() }}">@lang('laravel-livewire-tables::strings.loading')</td></tr>
44
</tbody>
55

66
<tbody wire:loading.remove>
77
@else
88
<tbody>
99
@endif
1010
@if($models->isEmpty())
11-
<tr><td colspan="{{ collect($columns)->count() }}">{{ $noResultsMessage }}</td></tr>
11+
<tr><td colspan="{{ collect($columns)->count() }}">@lang('laravel-livewire-tables::strings.no_results')</td></tr>
1212
@else
1313
@foreach($models as $model)
1414
<tr

resources/views/includes/_offline.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="row">
33
<div class="col-12">
44
<div wire:offline class="alert alert-danger">
5-
<i class="fa fa-info-circle"></i> {{ $offlineMessage }}
5+
<i class="fa fa-info-circle"></i> @lang('laravel-livewire-tables::strings.offline')
66
</div>
77
</div>
88
</div>

resources/views/includes/_options.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="row mb-4">
33
@if ($paginationEnabled && $perPageEnabled)
44
<div class="col form-inline">
5-
{{ $perPageLabel }}: &nbsp;
5+
@lang('laravel-livewire-tables::strings.per_page'): &nbsp;
66

77
<select wire:model="perPage" class="form-control">
88
@if (is_array($perPageOptions))
@@ -29,11 +29,11 @@
2929
@if ($disableSearchOnLoading) wire:loading.attr="disabled" @endif
3030
class="form-control"
3131
type="text"
32-
placeholder="{{ $searchLabel }}"
32+
placeholder="{{ __('laravel-livewire-tables::strings.search') }}"
3333
/>
3434
@if ($clearSearchButton)
3535
<div class="input-group-append">
36-
<button class="{{ $clearSearchButtonClass }}" type="button" wire:click="clearSearch">{{ $clearSearchButtonLabel }}</button>
36+
<button class="{{ $clearSearchButtonClass }}" type="button" wire:click="clearSearch">@lang('laravel-livewire-tables::strings.clear')</button>
3737
</div>
3838
</div>
3939
@endif

resources/views/includes/_pagination.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
</div>
66

77
<div class="col text-right text-muted">
8-
{{ __('Showing :first to :last out of :total results', ['first' => $models->count() ? $models->firstItem() : 0, 'last' => $models->count() ? $models->lastItem() : 0, 'total' => $models->total()]) }}
8+
@lang('laravel-livewire-tables::strings.results', [
9+
'first' => $models->count() ? $models->firstItem() : 0,
10+
'last' => $models->count() ? $models->lastItem() : 0,
11+
'total' => $models->total()
12+
])
913
</div>
1014
</div>
1115
@endif

src/LivewireTablesServiceProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ public function boot()
1616
{
1717
$this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-livewire-tables');
1818

19+
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-livewire-tables');
20+
1921
$this->publishes([
2022
__DIR__.'/../resources/views' => resource_path('views/vendor/laravel-livewire-tables'),
2123
]);
24+
25+
$this->publishes([
26+
__DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-livewire-tables'),
27+
]);
2228
}
2329
}

src/TableComponent.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,6 @@ abstract class TableComponent extends Component
4848
*/
4949
public $refresh = false;
5050

51-
/**
52-
* Use constructor instead of mount so that the child classes have access to a mount method that they can accept parameters in.
53-
*
54-
* TableComponent constructor.
55-
*
56-
* @param $id
57-
*/
58-
public function __construct($id)
59-
{
60-
parent::__construct($id);
61-
62-
$this->setTranslationStrings();
63-
}
64-
65-
/**
66-
* Sets the initial translations of these items.
67-
*/
68-
public function setTranslationStrings()
69-
{
70-
$this->loadingMessage = __('Loading...');
71-
$this->offlineMessage = __('You are not currently connected to the internet.');
72-
$this->noResultsMessage = __('There are no results to display for this query.');
73-
$this->perPageLabel = __('Per Page');
74-
$this->searchLabel = __('Search...');
75-
$this->clearSearchButtonLabel = __('Clear');
76-
}
77-
7851
/**
7952
* @return \Illuminate\Database\Eloquent\Builder
8053
*/

src/Traits/Loading.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,4 @@ trait Loading
2424
* @var bool
2525
*/
2626
public $disableSearchOnLoading = false;
27-
28-
/**
29-
* The loading message that gets displayed.
30-
*
31-
* @var string
32-
*/
33-
public $loadingMessage;
3427
}

0 commit comments

Comments
 (0)