Recently, I was tasked with building an application to be used by several clients in which everyone used a single codebase and database, but they could provide their own “lingo” for how form fields would show in the application. So if one of the model attributes was “department”, one client may refer to that as “group” whereas another might refer to it as “gaggle”.
My initial thought was to use Django’s fantastic i18n and localization features to provide separate translations for each client, but Django’s i18n support is truly supported for user-based locales and not some other arbitrary attribute of the user such as what company they work for. Since I couldn’t find a solution, I decided to put together an app I call django-lingo which provides a simple LabelCustomization model that ties a user to a set of label customizations as well as a form that you can extend in lieu of ModelForm that properly displays the customized labels if there are any. If no label customizations exist for a given field or a given user, the default field from the original model definition is used instead.
You can find django-lingo on Github here:
http://github.com/ryates/django-lingo/
What’s Next
Although tying the label customization to individual users worked for me (we only had one user per client using the application), it doesn’t hold up for many use cases so I intend to develop a more generic way to tie a set of label customizations to whatever group of folks that you want to see those customizations. I’m happy to have suggestions.
