Skip to content

Commit 5816b35

Browse files
committed
Support Multilingual & some customizations capabilities added
1 parent f3a5704 commit 5816b35

File tree

17 files changed

+191
-59
lines changed

17 files changed

+191
-59
lines changed

config/nested-comments.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,22 @@
3535
'allow-multiple-reactions' => env('ALLOW_MULTIPLE_REACTIONS', false), // Allow multiple reactions from the same user
3636
'allow-guest-reactions' => env('ALLOW_GUEST_REACTIONS', false), // Allow guest users to react
3737
'allow-guest-comments' => env('ALLOW_GUEST_COMMENTS', false), // Allow guest users to comment
38-
'mentions' => [
39-
'items-placeholder' => 'Search users by name or email address',
40-
'empty-items-message' => 'No users found',
41-
],
38+
39+
'format-created-date' => 'F j Y h:i:s A',
40+
/*
41+
|--------------------------------------------------------------------------
42+
| Livewire Component
43+
|--------------------------------------------------------------------------
44+
|
45+
*/
46+
'show-heading' => true,
47+
48+
'show-badge-counter' => true,
49+
'badge-counter-color' => 'info',
50+
51+
'show-refresh-button' => true,
52+
'style-refresh-button' => 'button', // 'button' or 'icon',
53+
'icon-refresh-button' => 'heroicon-m-sparkles',
54+
'outlined-refresh-button' => false,
55+
'color-refresh-button' => 'info' // 'danger', 'gray', 'info', 'success' or 'warning'
4256
];

resources/lang/en/nested-comments.php

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,55 @@
22

33
// translations for Coolsam/NestedComments
44
return [
5-
//
5+
'comments' => [
6+
'general' => [
7+
'guest' => 'Guest',
8+
'no_comments_provided' => 'No comments provided.',
9+
'no_commentable_record_set' => 'No Commentable record set.',
10+
'record_is_not_configured_for_reactions' => 'The current record is not configured for reactions. Please include the `HasReactions` trait to the model.',
11+
'no_commentable_record_found_widget' => 'No Commentable record found. Please pass a record to the widget.',
12+
'reply' => 'Reply',
13+
'no_replies' => 'No replies yet.',
14+
'comments' => 'Comments',
15+
],
16+
'form' => [
17+
'field' => [
18+
'comment' => [
19+
'label' => 'Your Comment',
20+
'mention_items_placeholder' => 'Search users by name or email address',
21+
'empty_mention_items_message' => 'No users found',
22+
23+
],
24+
],
25+
'buttons' => [
26+
'submit' => 'Submit',
27+
'cancel' => 'Cancel',
28+
'add_comment' => 'Add a new comment',
29+
'add_reply' => 'Add a reply',
30+
'reply' => 'Reply',
31+
'hide_replies' => 'Hide Replies',
32+
'refresh' => 'Refresh',
33+
]
34+
],
35+
'table' => [
36+
'actions' => [
37+
'view_comments' => [
38+
//'label' => 'View comment',
39+
'heading' => 'Comments',
40+
'close' => 'Close'
41+
]
42+
],
43+
],
44+
'actions' => [
45+
'view_comment' => [
46+
//'label' => 'View comment',
47+
'heading' => 'View Comments',
48+
'close' => 'Close'
49+
]
50+
]
51+
],
52+
'reactions' => [
53+
'add_reaction' => 'Add a reaction',
54+
]
55+
656
];
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
// translations for Coolsam/NestedComments
4+
return [
5+
'comments' => [
6+
'general' => [
7+
'guest' => 'Visiteur',
8+
'no_comments_provided' => 'Aucun commentaire enregistré.',
9+
'no_commentable_record_set' => 'Aucun `Commentable record` défini.',
10+
'record_is_not_configured_for_reactions' => 'L\'enregistrement actuel n\'est pas configuré pour les réactions. Veuillez inclure le trait `HasReactions` au modèle.',
11+
'no_commentable_record_found_widget' => 'Aucun `Commentable record` trouvé. Merci de passer le model au widget',
12+
'reply' => 'Réponse',
13+
'no_replies' => 'Aucune réponse.',
14+
'comments' => 'Commentaires',
15+
],
16+
'form' => [
17+
'field' => [
18+
'comment' => [
19+
'label' => '',
20+
//'label' => 'Votre Commentaire',
21+
'mention_items_placeholder' => 'Rechercher les utilisateurs par nom ou email',
22+
'empty_mention_items_message' => 'Aucun utilisateur trouvé',
23+
24+
],
25+
],
26+
'buttons' => [
27+
'submit' => 'Envoyer',
28+
'cancel' => 'Fermer',
29+
'add_comment' => 'Ajouter un nouveau commentaire',
30+
'add_reply' => 'Ajouter une réponse',
31+
'reply' => 'Répondre',
32+
'hide_replies' => 'Cacher les réponses',
33+
'refresh' => 'Rafraîchir',
34+
]
35+
],
36+
'table' => [
37+
'actions' => [
38+
'view_comments' => [
39+
'heading' => 'Commentaires',
40+
'close' => 'Fermer'
41+
]
42+
],
43+
],
44+
'actions' => [
45+
'view_comment' => [
46+
'heading' => 'Voir les Commentaires',
47+
'close' => 'Fermer'
48+
]
49+
]
50+
],
51+
'reactions' => [
52+
'add_reaction' => 'Ajouter une réaction',
53+
]
54+
55+
];

resources/views/components/comment-card.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
/>
99
@else
1010
<p class="text-gray-500 dark:text-gray-400">
11-
{{ __('No comment provided.') }}
11+
{{ __('nested-comments::nested-comments.comments.general.no_comments_provided') }}
1212
</p>
13-
@endif
13+
@endif
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@if(isset($record))
22
<livewire:nested-comments::comments :record="$record" />
33
@else
4-
<p>No Commentable record set.</p>
5-
@endif
4+
<p>{{ __('nested-comments::nested-comments.comments.general.no_commentable_record_set') }}</p>
5+
@endif

resources/views/components/reactions.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
@if(app(\Coolsam\NestedComments\NestedComments::class)->classHasTrait($record, \Coolsam\NestedComments\Concerns\HasReactions::class))
66
<livewire:nested-comments::reaction-panel :record="$record"/>
77
@else
8-
<p>__('The current record is not configured for reactions. Please include the `HasReactions` trait to the model.')</p>
8+
<p>{{ __('nested-comments::nested-comments.comments.general.record_is_not_configured_for_reactions') }}</p>
99
@endif
10-
@endif
10+
@endif

resources/views/filament/widgets/comments-widget.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<livewire:nested-comments::comments :record="$this->record" />
44
@else
55
<x-filament::section>
6-
No Commentable record found. Please pass a record to the widget.
6+
{{ __('nested-comments::nested-comments.comments.general.no_commentable_record_found_widget') }}
77
</x-filament::section>
88
@endif
99
</x-filament-widgets::widget>

resources/views/livewire/add-comment.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<form wire:submit.prevent="create" wire:loading.attr="disabled" class="space-y-4">
44
{{ $this->form }}
55
<x-filament::button type="submit">
6-
Submit
6+
{{ __('nested-comments::nested-comments.comments.form.buttons.submit') }}
77
</x-filament::button>
88
<x-filament::button type="button" color="gray" wire:click="showForm(false)">
9-
Cancel
9+
{{ __('nested-comments::nested-comments.comments.form.buttons.cancel') }}
1010
</x-filament::button>
1111
</form>
1212
@else
1313
<x-filament::input.wrapper
1414
:inline-prefix="true"
1515
prefix-icon="heroicon-o-chat-bubble-bottom-center-text">
1616
<x-filament::input
17-
:placeholder="$this->replyTo?->getKey() ? 'Add a reply' : 'Add a new comment'"
17+
:placeholder="$this->replyTo?->getKey() ? __('nested-comments::nested-comments.comments.form.buttons.add_reply') : __('nested-comments::nested-comments.comments.form.buttons.add_comment')"
1818
type="text"
1919
wire:click.prevent.stop="showForm(true)"
2020
:readonly="true"

resources/views/livewire/comment-card.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class="text-xs text-gray-500 dark:text-gray-400">
1919
</p>
2020
<p x-show="showFullDate"
2121
class="text-xs text-gray-500 dark:text-gray-400"
22-
>{{ $this->comment->created_at->format('F j Y h:i:s A') }}</p>
22+
>{{ $this->comment->created_at->format(config('nested-comments.format-created-date', 'F j Y h:i:s A')) }}</p>
2323
</div>
2424
</div>
2525
</div>
@@ -34,11 +34,11 @@ class="cursor-pointer"
3434
wire:click.prevent="toggleReplies">
3535
@if($this->comment->replies_count > 0)
3636
<span title="{{ \Illuminate\Support\Number::format($this->comment->replies_count) }}">
37-
{{\Illuminate\Support\Number::forHumans($this->comment->replies_count, maxPrecision: 3, abbreviate: true)}} {{ str('Reply')->plural($this->comment->replies_count) }}
37+
{{\Illuminate\Support\Number::forHumans($this->comment->replies_count, maxPrecision: 3, abbreviate: true)}} {{ str(__('nested-comments::nested-comments.comments.general.reply'))->plural($this->comment->replies_count) }}
3838
</span>
3939
@else
40-
<span title="{{__('No replies yet')}}">
41-
Reply
40+
<span title="{{ __('nested-comments::nested-comments.comments.general.no_replies') }}">
41+
{{ __('nested-comments::nested-comments.comments.form.buttons.reply') }}
4242
</span>
4343
@endif
4444
</x-filament::link>
@@ -67,7 +67,7 @@ class="cursor-pointer"
6767
}
6868
"
6969
type="button"
70-
label="Hide replies" icon="heroicon-o-minus-circle" class="absolute -left-8 -bottom-4" wire:click.prevent="toggleReplies"/>
70+
label="{{ __('nested-comments::nested-comments.comments.form.buttons.hide_replies') }}" tooltip="{{ __('nested-comments::nested-comments.comments.form.buttons.hide_replies') }}" icon="heroicon-o-minus-circle" class="absolute -left-8 -bottom-4" wire:click.prevent="toggleReplies"/>
7171
</div>
7272
@endif
7373
</div>
@@ -79,4 +79,4 @@ class="cursor-pointer"
7979
element.classList.add(['comment-mention']);
8080
});
8181
</script>
82-
@endscript
82+
@endscript

resources/views/livewire/comments.blade.php

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
<x-filament::section wire:poll.10s :compact="true" class="!ring-0 !shadow-none !p-0">
2-
<x-slot name="heading">
3-
<div class="flex items-center space-x-2">
4-
<div>
5-
{{ __('Comments') }}
2+
@if(config('nested-comments.show-heading', true))
3+
<x-slot name="heading">
4+
<div class="flex items-center space-x-2">
5+
<div>
6+
{{ __('nested-comments::nested-comments.comments.general.comments') }}
7+
</div>
8+
@if(config('nested-comments.show-badge-counter', true))
9+
<div>
10+
<x-filament::badge :color="config('nested-comments.badge-counter-color', 'danger')" :title="$this->comments->count()">
11+
{{\Illuminate\Support\Number::forHumans($this->comments->count(),maxPrecision: 3, abbreviate: true)}}
12+
</x-filament::badge>
13+
</div>
14+
@endif
615
</div>
7-
<div>
8-
<x-filament::badge color="danger" :title="$this->comments->count()">
9-
{{\Illuminate\Support\Number::forHumans($this->comments->count(),maxPrecision: 3, abbreviate: true)}}
10-
</x-filament::badge>
11-
</div>
12-
</div>
13-
</x-slot>
14-
<x-slot name="headerEnd">
15-
<x-filament::button wire:click.prevent="refreshComments()">Refresh</x-filament::button>
16-
</x-slot>
16+
</x-slot>
17+
@endif
18+
@if(config('nested-comments.show-refresh-button', true))
19+
<x-slot name="headerEnd">
20+
<x-filament::button
21+
wire:click.prevent="refreshComments()"
22+
:color="config('nested-comments.color-refresh-button')"
23+
:icon="config('nested-comments.icon-refresh-button')"
24+
:outlined="config('nested-comments.outlined-refresh-button')"
25+
:tooltip="config('nested-comments.style-refresh-button', 'button') === 'icon' ? __('nested-comments::nested-comments.comments.form.buttons.refresh') : null"
26+
>
27+
@if(config('nested-comments.style-refresh-button', 'button') === 'button')
28+
{{ __('nested-comments::nested-comments.comments.form.buttons.refresh') }}
29+
@endif
30+
</x-filament::button>
31+
</x-slot>
32+
@endif
1733
@foreach($this->comments as $comment)
1834
<livewire:nested-comments::comment-card
1935
:key="$comment->getKey()"

0 commit comments

Comments
 (0)