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

Slug field also needs translation. #12

Closed
bartlomiej84 opened this issue Oct 6, 2012 · 9 comments
Closed

Slug field also needs translation. #12

bartlomiej84 opened this issue Oct 6, 2012 · 9 comments

Comments

@bartlomiej84
Copy link

Great bundle - saved me a lof of time.

Anyway, I was wondering if there's any way to slugify the translation (one of the fields).

First problem is that slug field is always visible. Tried using display option but with no results. I accomplished that using 'type' => 'hidden' option.

But still, my slug is not generated. When persisting translation entities as it is in gedmo's tutorials, the english translation slug field is generated from english translation name field.

But when using this bundle the slug field is not even in database.

Do you have solution to this problem, or it is a common restriction.

Thanks!

@webda2l
Copy link
Member

webda2l commented Oct 7, 2012

Hello,

About the display option, it works for me, you can maybe copy/paste your code here.

About the slug, it's true that currently, it doesn't work for all locales. Normally, it work only for the default_locale (normally force in your edit method as https://github.com/a2lix/DemoTranslationBundle/blob/master/src/A2lix/DemoTranslationBundle/Controller/Backend/ProductController.php#L57).

I've got already some pending commits and start to think about a way for resolve this ticket.

Regards

@bartlomiej84
Copy link
Author

In my case slug for default locale is generated. It is not generated only for translations when annotated with gedmo like that.

/**
 * @Gedmo\Slug(fields={"name"})
 * @Gedmo\Translatable
 * @ORM\Column(name="slug", type="string", length=70)
 */
private $slug;

As your working on this feature, for now on I disabled slug translations. But it would be great to have translated slug in urls for different locales.

Thanks!

@webda2l
Copy link
Member

webda2l commented Oct 7, 2012

Yes we are agree :)

@rodrigobb
Copy link
Contributor

First of all thanks for this bundle. It's a timesaver.

I'm using an internationalized slug internally generated by the Gedmo\Sluggable\Sluggable, so I don't want it to be in the edit form.

If I set 'display' => false, an exception raises so my only workaround now is to make it visible but readonly. I think it's not a good solution so please, fix this issue if you can.

Thanks in advance.

@a2lix
Copy link
Collaborator

a2lix commented Jan 2, 2013

You're welcome.

I plan to write some tests before resolve your problem and probably do some refactoring.
But I'm not sure to find the time before the end of the month...

You can copy/paste your exception

@rodrigobb
Copy link
Contributor

The exception raised is the usual "duplicated key" (but was an update, not an insert).

[2/2] DBALException: An exception occurred while executing 'INSERT INTO page_translations (locale, field, content, object_id) VALUES (?, ?, ?, ?)' with params {"1":"es","2":"slug","3":"titulo-de-la-pagina","4":1}:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'es-1-slug' for key 'lookup_unique_idx'
[1/2] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'es-1-slug' for key 'lookup_unique_idx'

@sfblaauw
Copy link

any news?

@bartlomiej84
Copy link
Author

I still use my original language for slug when the user is in other language. It would be great if this bundle would slugify some field in other language. Still waiting for this issue.

@webda2l Do you plan to have a look at this issue?

Thanks for this great bundle, anyway!

@webda2l
Copy link
Member

webda2l commented Mar 11, 2013

This must be resolve in DoctrineExtensionBundle for be clean.
https://github.com/l3pp4rd/DoctrineExtensions/issues/415 and https://github.com/l3pp4rd/DoctrineExtensions/issues/542 are about this problem.
I have added a comment in the first issue.

@webda2l webda2l closed this as completed Aug 8, 2016
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

4 participants