nova-sluggable
nova-sluggable copied to clipboard
Translation with "optimistdigital/nova-translatable"
Hey there, thank you for your great Package!
Recently i needed to get it working with the Package: "optimistdigital/nova-translatable" and found a pretty easy way to get it working.
In "resources/js/components/SluggableText/FormField.vue" in Line 27 (handleChange()) i edited the Function like this:
handleChange(event) {
let lang = this.field.attribute.split('.').length() > 1
? this.field.attribute.split('.').pop()
: null
let name = this.slugField
if(lang) {
name += '-' + lang
}
Nova.$emit('field-update-' + event.type + '-' + name, {
value: event.target.value
})
},
In "resources/js/components/Slug/FormField.vue" in Line 39 (mounted()) i edited the Function like this:
mounted() {
const eventType = this.field.options.event || 'keyup';
let lang = this.field.attribute.split('.').length() > 1
? this.field.attribute.split('.').pop()
: null
let name = this.field.name
if(lang) {
name += '-' + lang
}
Nova.$on('field-update-' + eventType + '-' + name, ({value}) => {
this.generateSlug(value)
})
},
This also works without translatable. Maybe you can integrate this to the existing Package.
Best Julian