Skip to content

Commit c6daff4

Browse files
Add localization support for seo pro fields (#160)
* Add localization support for seo pro fields * Read `localizable` on front end. Co-authored-by: Jesse Leite <jesseleite@gmail.com>
1 parent 3aa9cd2 commit c6daff4

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

resources/dist/js/cp.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.

resources/js/components/fieldtypes/SeoProFieldtype.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:config="field"
77
:value="value[field.handle]"
88
:meta="meta.meta[field.handle]"
9-
:read-only="isReadOnly"
9+
:read-only="! field.localizable"
1010
class="form-group"
1111
@meta-updated="metaUpdated(field.handle, $event)"
1212
@focus="$emit('focus')"

resources/js/components/fieldtypes/SourceFieldtype.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<v-select
66
:options="sourceTypeSelectOptions"
77
:reduce="option => option.value"
8-
:disabled="isReadOnly"
8+
:disabled="! config.localizable"
99
:clearable="false"
1010
v-model="source"
1111
/>
@@ -20,7 +20,7 @@
2020

2121
<div v-else-if="source === 'field'" class="source-field-select">
2222
<!-- TODO: Implement field suggestions v-select -->
23-
<text-input v-model="sourceField" :disabled="isReadOnly" />
23+
<text-input v-model="sourceField" :disabled="! config.localizable" />
2424
</div>
2525

2626
<component
@@ -30,7 +30,7 @@
3030
:config="fieldConfig"
3131
:value="value.value"
3232
:meta="meta.fieldMeta"
33-
:read-only="isReadOnly"
33+
:read-only="! config.localizable"
3434
handle="source_value"
3535
@input="updateValue">
3636
</component>

src/Fields.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function getConfig()
4949
'instructions' => __("seo-pro::fieldsets/{$langFile}.enabled_instruct"),
5050
'type' => 'toggle',
5151
'default' => true,
52+
'localizable' => true,
5253
],
5354
],
5455
[
@@ -59,6 +60,7 @@ public function getConfig()
5960
'placeholder' => $this->getPlaceholder('title'),
6061
'type' => 'seo_pro_source',
6162
'disableable' => true,
63+
'localizable' => true,
6264
'field' => [
6365
'type' => 'text',
6466
],
@@ -71,6 +73,7 @@ public function getConfig()
7173
'instructions' => __("seo-pro::fieldsets/{$langFile}.description_instruct"),
7274
'placeholder' => $this->getPlaceholder('description'),
7375
'type' => 'seo_pro_source',
76+
'localizable' => true,
7477
'field' => [
7578
'type' => 'textarea',
7679
],
@@ -85,6 +88,7 @@ public function getConfig()
8588
'type' => 'seo_pro_source',
8689
'from_field' => false,
8790
'disableable' => true,
91+
'localizable' => true,
8892
'field' => false,
8993
],
9094
],
@@ -96,6 +100,7 @@ public function getConfig()
96100
'placeholder' => $this->getPlaceholder('site_name_position'),
97101
'type' => 'seo_pro_source',
98102
'from_field' => false,
103+
'localizable' => true,
99104
'field' => [
100105
'type' => 'select',
101106
'options' => [
@@ -114,6 +119,7 @@ public function getConfig()
114119
'placeholder' => $this->getPlaceholder('site_name_separator'),
115120
'type' => 'seo_pro_source',
116121
'from_field' => false,
122+
'localizable' => true,
117123
'field' => [
118124
'type' => 'text',
119125
],
@@ -126,6 +132,7 @@ public function getConfig()
126132
'instructions' => __("seo-pro::fieldsets/{$langFile}.canonical_url_instruct"),
127133
'placeholder' => $this->isContent ? $this->getPlaceholder('canonical_url') : false,
128134
'type' => 'seo_pro_source',
135+
'localizable' => true,
129136
'field' => $this->isContent ? ['type' => 'text'] : false,
130137
],
131138
],
@@ -138,6 +145,7 @@ public function getConfig()
138145
'type' => 'seo_pro_source',
139146
'from_field' => false,
140147
'disableable' => true,
148+
'localizable' => true,
141149
'field' => [
142150
'type' => 'select',
143151
'create' => true,
@@ -156,6 +164,7 @@ public function getConfig()
156164
'instructions' => __("seo-pro::fieldsets/{$langFile}.image_instruct"),
157165
'placeholder' => $this->getPlaceholder('image'),
158166
'type' => 'seo_pro_source',
167+
'localizable' => true,
159168
'allowed_fieldtypes' => [
160169
'assets',
161170
],
@@ -168,6 +177,7 @@ public function getConfig()
168177
'display' => __("seo-pro::fieldsets/{$langFile}.twitter_handle"),
169178
'instructions' => __("seo-pro::fieldsets/{$langFile}.twitter_handle_instruct"),
170179
'type' => 'seo_pro_source',
180+
'localizable' => true,
171181
'field' => [
172182
'type' => 'text',
173183
],
@@ -183,6 +193,7 @@ public function getConfig()
183193
'disableable' => true,
184194
'field' => false,
185195
'from_field' => false,
196+
'localizable' => true,
186197
],
187198
],
188199
[
@@ -192,6 +203,7 @@ public function getConfig()
192203
'instructions' => __("seo-pro::fieldsets/{$langFile}.priority_instruct"),
193204
'placeholder' => $this->getPlaceholder('priority'),
194205
'type' => 'seo_pro_source',
206+
'localizable' => true,
195207
'field' => [
196208
'type' => 'text',
197209
],
@@ -204,6 +216,7 @@ public function getConfig()
204216
'instructions' => __("seo-pro::fieldsets/{$langFile}.change_frequency_instruct"),
205217
'placeholder' => $this->getPlaceholder('change_frequency'),
206218
'type' => 'seo_pro_source',
219+
'localizable' => true,
207220
'field' => [
208221
'type' => 'select',
209222
'options' => [

0 commit comments

Comments
 (0)