Skip to content

Instantly share code, notes, and snippets.

@matthiask
Created April 13, 2017 12:15
Show Gist options
  • Save matthiask/5cf10f8327befe5060a189adffabdd83 to your computer and use it in GitHub Desktop.
Save matthiask/5cf10f8327befe5060a189adffabdd83 to your computer and use it in GitHub Desktop.
django-modeltranslation translation options helper
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