Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation with "optimistdigital/nova-translatable" #30

Open
julianlaibach opened this issue Feb 28, 2022 · 0 comments
Open

Translation with "optimistdigital/nova-translatable" #30

julianlaibach opened this issue Feb 28, 2022 · 0 comments

Comments

@julianlaibach
Copy link

julianlaibach commented Feb 28, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant