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

Compatible with translatable #10

Open
trawen opened this issue Jan 18, 2019 · 9 comments
Open

Compatible with translatable #10

trawen opened this issue Jan 18, 2019 · 9 comments

Comments

@trawen
Copy link

trawen commented Jan 18, 2019

I tried two packages:

https://github.com/spatie/nova-translatable
https://github.com/mrmonat/nova-translatable

and this package does not work with any of them.

@thanoseleftherakos
Copy link

Any update on this?
It would be very useful to support translatable

@tomhatzer
Copy link
Owner

The problem is basically that the field names have spaces when using them as translatable fields. The events emitted don't get triggered due to the spaces inside (invalid event names). There are a few other things that would need to be changed, but basically "slugifying" the field names before using them would be a big step forward.

@benjaminhirsch
Copy link
Collaborator

benjaminhirsch commented Apr 21, 2019

Unfortunately this has to be done by the maintainers of those packages, there's nothing I can do on my side as far as I can see. Maybe you wanna ping @freekmurze and ask nicely or add the neccessary functionality by yourself to the translatable package and open an PR. :)

@Grunkhead
Copy link

@trawen is there any progression? I am also looking forward to a solution.

@Casper-Bastiaan-Net
Copy link

Casper-Bastiaan-Net commented Oct 21, 2019

I managed to get this package working with https://github.com/spatie/nova-translatable by changing the slug pointer on the text field from

TextWithSlug::make('field')
                    ->slug('{my_slug_name}')

to

TextWithSlug::make('field')
                    ->slug('translations_{my_slug_name}_{locale}')

as the spatie translation package adds those prefixes and suffixes to its translation field names

@ghost
Copy link

ghost commented Nov 9, 2019

@Casper-Bastiaan-Net So did you get a slug in your respective language automated - e.g when you enter the title in Arabic letters then slug should become in Arabic letters too?

https://prnt.sc/puj69b

@Grunkhead
Copy link

@asharma16891 have you tried changing app's locale? This might work.

@sanneterpstra
Copy link

sanneterpstra commented Mar 10, 2020

@Casper-Bastiaan-Net Could you explain how you did this?

I have two locales: EN and NL. Currently my code looks like this:
Translatable::make([
TextWithSlug::make('title')->rules('required')->slug('translations_slug_nl'),
Slug::make('slug'),
]),

The NL field works like a charm but how can I get the EN slug field linked to the EN title field? Is there a variable you can use to replace 'translations_slug_nl' with 'translations_slug_$locale' or something?

@Grunkhead
Copy link

Grunkhead commented Mar 19, 2020

@sanneterpstra

For the non translated version you have to just use the regular notation.

For the translated version you have to add the translations locale at the end of the name manually.

->slug('translations_slug_' . $locale')

image

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

7 participants