Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
733 changes: 1 addition & 732 deletions dist/js/tool.js

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions resources/js/components/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<template v-if="hasCommenter">
<a class="no-underline dim text-primary font-bold" :href="commenterUrl" v-text="commenter"></a>

said
{{ __('said') }}
</template>

<template v-else>
Written
{{ __('Written') }}
</template>

{{ date }}
Expand Down Expand Up @@ -45,23 +45,25 @@
},

date() {
const language = Nova.app.__('Moment Locale');
moment.locale(language)
let now = moment();
let date = moment.utc(_.find(this.comment.fields, { attribute: 'created_at' }).value)
.tz(moment.tz.guess());

if (date.isSame(now, 'minute')) {
return 'just now';
return Nova.app.__('just now');
}

if (date.isSame(now, 'day')) {
return `at ${date.format('LT')}`;
return Nova.app.__('at') + ' ' + date.format('LT');
}

if (date.isSame(now, 'year')) {
return `on ${date.format('MMM D')}`;
return Nova.app.__('on') + ' ' + (language === 'de' ? date.format('D MMM') : date.format('MMM D'));
}

return `on ${date.format('ll')}`;
return Nova.app.__('on') + ' ' + date.format('ll');
},

hasCommenter() {
Expand Down
16 changes: 8 additions & 8 deletions resources/js/components/Tool.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<div>
<h4 class="text-90 font-normal text-2xl mb-3">
Comments
{{ __('Comments') }}
</h4>

<div class="card mb-6 overflow-hidden">
<div class="flex border-b border-40 remove-bottom-border px-8">
<div class="w-full pt-6 pb-2">
<h4 class="font-normal text-80">
Write new comment
{{ __('Write new comment') }}
</h4>

<textarea class="w-full form-control form-input form-input-bordered py-3 h-auto mt-2"
Expand All @@ -23,19 +23,19 @@

<div class="flex justify-between px-8 pb-4 border-b border-40">
<div class="help-text">
On MacOS, press ⌘ + Enter to save
{{ __('On MacOS, press ⌘ + Enter to save') }}
</div>

<button class="btn btn-default btn-primary inline-flex items-center relative mt-4"
type="submit"
@click="createComment">
Save Comment
{{ __('Save Comment') }}
</button>
</div>

<div class="flex border-b border-40 remove-bottom-border px-8" v-if="hasComments">
<div class="w-full py-6">
<h3 class="text-90 font-bold text-lg mb-4">Comments</h3>
<h3 class="text-90 font-bold text-lg mb-4">{{ __('Comments') }}</h3>

<comment :comment="comment" v-for="(comment, key) in data.resources" :key="key"></comment>
</div>
Expand All @@ -47,14 +47,14 @@
:class="paginationClass(hasNextLink)"
:disabled="! hasNextLink"
@click="getComments(data.next_page_url)">
Older
{{ __('Older') }}
</button>

<button class="btn btn-link py-3 px-4"
:class="paginationClass(hasPrevLink)"
:disabled="! hasPrevLink"
@click="getComments(data.prev_page_url)">
Newer
{{ __('Newer') }}
</button>
</nav>
</div>
Expand Down Expand Up @@ -131,7 +131,7 @@

this.resetComment();

this.$toasted.show(`A new comment has been created.`, { type: 'success' });
this.$toasted.show(Nova.app.__('A new comment has been created.'), { type: 'success' });
})
.catch(response => this.$toasted.show(response, { type: 'error' }));
},
Expand Down
19 changes: 19 additions & 0 deletions resources/lang/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Comments" : "Kommentare",
"Comment" : "Kommentar",
"Commentable" : "Kommentierbar",
"Commenter" : "Kommentare",
"Created" : "Erstellt",
"Write new comment" : "Erstelle einen neuen Kommentar",
"On MacOS, press ⌘ + Enter to save" : "Zum Speichern unter MacOS, bitte ⌘ + Enter drücken",
"Save Comment" : "Kommentar speichern",
"Older" : "Älter",
"Newer" : "Neuer",
"A new comment has been created." : "Ein neuer Kommentar wurde erstellt.",
"Written" : "Geschrieben",
"said" : "schrieb",
"Moment Locale" : "de",
"just now" : "Gerade eben",
"at" : "um",
"on" : "am"
}
19 changes: 19 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Comments" : "Comments",
"Comment" : "Comment",
"Commentable" : "Commentable",
"Commenter" : "Commenter",
"Created" : "Created",
"Write new comment" : "Write new comment",
"On MacOS, press ⌘ + Enter to save" : "On MacOS, press ⌘ + Enter to save",
"Save Comment" : "Save Comment",
"Older" : "Older",
"Newer" : "Newer",
"A new comment has been created." : "A new comment has been created.",
"Written" : "Written",
"said" : "said",
"Moment Locale" : "en",
"just now" : "just now",
"at" : "at",
"on" : "on"
}
2 changes: 1 addition & 1 deletion src/Commenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Commenter extends ResourceTool
*/
public function name()
{
return 'Commenter';
return __('Commenter');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/CommentsPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CommentsPanel extends Panel
*/
public function __construct()
{
parent::__construct('Comments', $this->prepareFields($this->fields()));
parent::__construct(__('Comments'), $this->prepareFields($this->fields()));
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Nova/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ class Comment extends Resource
public function fields(Request $request)
{
return [
Textarea::make('comment')
Textarea::make(__('Comment'), 'comment')
->alwaysShow()
->hideFromIndex(),

MorphTo::make('Commentable')->onlyOnIndex(),
MorphTo::make(__('Commentable'), 'Commentable')->onlyOnIndex(),

Text::make('comment')
Text::make(__('Comment'), 'comment')
->displayUsing(function ($comment) {
return Str::limit($comment, config('nova-comments.limit'));
})
->onlyOnIndex(),

BelongsTo::make('Commenter', 'commenter', config('nova-comments.commenter.nova-resource'))
BelongsTo::make(__('Commenter'), 'commenter', config('nova-comments.commenter.nova-resource'))
->exceptOnForms(),

DateTime::make('Created', 'created_at')
DateTime::make(__('Created'), 'created_at')
->format(config('nova-comments.date-format'))
->exceptOnForms()
->sortable(),
Expand Down
18 changes: 18 additions & 0 deletions src/NovaCommentsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ class NovaCommentsServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->publishes([
__DIR__.'/../resources/lang/' => resource_path('lang/vendor/nova-comments'),
]);

$this->loadJSONTranslationsFrom(resource_path('lang/vendor/nova-comments'));

$this->config();
$this->migrations();
$this->nova();

$this->app->booted(function (): void {
$this->translations();
});
}

/**
Expand Down Expand Up @@ -60,4 +70,12 @@ function () {
}
);
}

public function translations(): void
{
$locale = $this->app->getLocale();

Nova::translations(__DIR__.'/../resources/lang/'.$locale.'.json');
Nova::translations(resource_path('lang/vendor/nova-comments/'.$locale.'.json'));
}
}