Skip to content

Commit e95f27c

Browse files
committed
#3 Use translations (basic)
1 parent 63e541f commit e95f27c

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"/js/field.js": "/js/field.js?id=a9e4b55019bad3275d91"
2+
"/js/field.js": "/js/field.js?id=06b32463f59a0749766c"
33
}

resources/js/components/FormField.vue

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class="text-xs bg-90 hover:bg-black text-white font-semibold rounded-sm px-4 py-1 m-1 form-input-bordered"
88
@click="toggleFullscreen"
99
type="button">
10-
{{ fullscreenButtonText.on }}
10+
{{ __('Enter fullscreen') }}
1111
</button>
1212
</div>
1313
<div :id=containerId :style="{height: field.height || '800px'}" class="form-input-bordered"></div>
@@ -26,13 +26,6 @@
2626
2727
props: ['resourceName', 'resourceId', 'field'],
2828
29-
data: () => ({
30-
fullscreenButtonText: {
31-
on: '▶ Enter fullscreen',
32-
off: '✖︎ Exit fullscreen',
33-
},
34-
}),
35-
3629
created() {
3730
this.injectUnlayerScript(this.initEditor);
3831
},
@@ -56,9 +49,10 @@
5649
controls.classList.toggle('stickyControls');
5750
5851
const toggleButton = controls.querySelector(`#fullscreenToggleButton`);
52+
const trans = Nova.app.$options.methods.__;
5953
unlayerEditorContainer.classList.contains('fullscreen')
60-
? toggleButton.innerText = this.fullscreenButtonText.off
61-
: toggleButton.innerText = this.fullscreenButtonText.on;
54+
? toggleButton.innerText = trans('Exit fullscreen')
55+
: toggleButton.innerText = trans('Enter fullscreen');
6256
},
6357
6458
/**

resources/lang/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"Enter fullscreen": "▶ Enter fullscreen",
3+
"Exit fullscreen": "✖︎ Exit fullscreen"
4+
}

src/ServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@ public function boot(): void
1313
Nova::serving(function () {
1414
Nova::script('nova-unlayer-field', __DIR__.'/../dist/js/field.js');
1515
});
16+
17+
$this->registerTranslations();
18+
}
19+
20+
protected function registerTranslations(): void
21+
{
22+
$currentLocale = app()->getLocale();
23+
24+
Nova::translations(__DIR__."/../resources/lang/$currentLocale.json");
1625
}
1726
}

0 commit comments

Comments
 (0)