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

Add modeltranslation support #25

Open
fabiocaccamo opened this issue Apr 5, 2017 · 6 comments
Open

Add modeltranslation support #25

fabiocaccamo opened this issue Apr 5, 2017 · 6 comments

Comments

@fabiocaccamo
Copy link
Contributor

Steps to reproduce the problem:

  • more languages, for example: en, it, fr
  • default language: en
  • modeltranslation installed
  • model with a name field and a slug field populated from name
  • name and slug fields are marked for translation in translation.py
  • in the admin populate the name field for all languages using the different values and save it

Current result:
All slug values are always (for all languages) the slugified version of name in the default language:

slug_en populated from name_en
slug_it populated from name_en
slug_fr populated from name_en

Expected result:
Each slug value should be the slugified version of name for the corresponding language:

slug_en populated from name_en
slug_it populated from name_it
slug_fr populated from name_fr

Dirty solution overriding model save method:

#requires always_update = False
def save(self, *args, **kwargs):
    
    for lang_code, lang_verbose in settings.LANGUAGES:
        lang_code = lang_code.replace('-', '_')
        
        setattr(self, 'slug_%s' % lang_code, slugify( getattr(self, 'name_%s' % lang_code, u'') ))
        
    super( NameSlugModel, self ).save( *args, **kwargs )
@fabiocaccamo
Copy link
Contributor Author

Check PR #26

@fabiocaccamo
Copy link
Contributor Author

Any update about this issue?

@parruc
Copy link

parruc commented Oct 17, 2021

+1 It would be really great to have such feature out of the box!!!

@fabiocaccamo
Copy link
Contributor Author

@justinmayer @parruc still interested in a PR for this issue?

@parruc
Copy link

parruc commented Jul 4, 2022

I have done it the ugly way in the save method so I do not strictly need it but I still think it would be beneficial for the project: urls are often based on slugs and having translated slugs that comes from specific language titles would helps with website positioning and user friendliness of the site IMO.

@fabiocaccamo
Copy link
Contributor Author

@parruc I have the impression that this project is a little bit abandoned by the maintainer.

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

2 participants