How can you solve the problem of separating the output text and code, and write only the key in the code?
Task: It is necessary to remove all the text from the code and from the template is valid in the json file.
At the moment there is such a solution:
{ 'sc.site_name' : 'Site name', 'sc.phone_number' : 'Phone number', 'sc.email' : 'E-mail', 'sc.skype' : 'Skype', } And an example in the model:
class SiteConfiguration(SingletonModel): site_name = models.CharField(verbose_name = json_local['sc.site_name']) phone_number = PhoneNumberField(verbose_name = json_local['sc.phone_number']) email = models.EmailField(verbose_name = json_local['sc.email']) skype = models.CharField(verbose_name = json_local['sc.skype']) Completed the question:
Perhaps a similar approach to use in conjunction with gettext? I may not understand why gettext is needed, but how effective is it in terms of performance and convenience to store text in * .po files and use keys in msgid?
Example of structure in JSON (for illustrative example):
{ 'sc.site_name': { 'ru': 'Имя сайта', 'us': 'Site name', ... } ... } And in the file * .po:
# ru.po msgid "sc.site_name" msgstr "Название сайта" # us.po msgid "sc.site_name" msgstr "Site name"