I'm writing a multilanguage application for renting out property. I've succesfully translated all of the static content inside my application, but the input that the user gives is dynamic and needs to be translated by them.
Example:
The user needs to create all the different rental types that are available for a client to choose from. However, for each language this type has a different name because it needs to be translated. Ideally, when creating a rental type, the user should see multiple input fields for the name: one for each language. Django should then determine by the client's language which name to show.
I've tried using django-modeltranslation and that created some extra columns on my database, but I cannot find a way for a user to edit all of these columns from one view.
This is my translation.py
# translation.py
from modeltranslation.translator import register, TranslationOptions
from .models import RentalType, Costs
@register(RentalType)
class RentalTypeTranslationOptions(TranslationOptions):
fields = ('type', 'slug')
@register(Costs)
class CostTranslationOptions(TranslationOptions):
fields = ('name',)
Which were succesfully migrated to my database:
Migrations for 'main':
main\migrations\0014_auto_20211202_1559.py
- Add field name_en to costs
- Add field name_fr to costs
- Add field name_nl to costs
- Add field slug_en to rentaltype
- Add field slug_fr to rentaltype
- Add field slug_nl to rentaltype
- Add field type_en to rentaltype
- Add field type_fr to rentaltype
- Add field type_nl to rentaltype
Is there a way to serve one view to the user that contains multiple input fields for the different languages? (e.g. field: name, three languages - there are three input fields)
The documentation didn't help me further. Thanks in advance.