Created
April 13, 2017 12:15
-
-
Save matthiask/5cf10f8327befe5060a189adffabdd83 to your computer and use it in GitHub Desktop.
django-modeltranslation translation options helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
from modeltranslation.translator import translator, TranslationOptions | |
from naturnetz.models import Branch, Staffer, StickyNote | |
def translation_options(model, **options): | |
translator.register( | |
model, | |
type( | |
str('%sTranslationOptions' % model.__name__), | |
(TranslationOptions,), | |
options, | |
), | |
) | |
translation_options( | |
Branch, | |
fields=('title', 'page'), | |
) | |
translation_options( | |
Staffer, | |
fields=('function', 'description', 'contact'), | |
) | |
translation_options( | |
StickyNote, | |
fields=('note', 'url'), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment