예제 #1
0
파일: services.py 프로젝트: Bisk1/kongming
 def set_text_translations(self, source_text, source_language, translations):
     """
     Set translations of the source text in source language to the specified translations
     :param source_text: text to translate
     :param source_language: language of text to translate
     :param translations: translations of the text to translate
     :return: nothing
     """
     business_text_to_translate, _ = BusinessText.objects.get_or_create(text=source_text, language=source_language.value)
     business_text_to_translate.translations.clear()
     for translation in translations:
         translation_language = Languages.other_language(source_language)
         business_translation, _ = BusinessText.objects.get_or_create(text=translation, language=translation_language.value)
         business_text_to_translate.translations.add(business_translation)
     return
예제 #2
0
파일: models.py 프로젝트: Bisk1/kongming
 def add_translation(self, translation_text):
     translation_language = Languages.other_language(Languages(self.language))
     business_translation, _ = BusinessText.objects.get_or_create(text=translation_text,
                                                                  language=translation_language.value)
     self.translations.add(business_translation)