Пример #1
0
 def modify_localization_json(self, localized_json, key, translation):
     """ updates localization json with new text, or removes
         a language key of the text is blank
     """
     translation = translation.strip()
     if not isinstance(localized_json, dict):
         localized_json = LastUpdatedOrderedDict()
     if key != self.DEFAULT_LANGUAGE:
         # we will only modify localizations if the key is not
         # the same as the default language
         if len(translation) > 1:
             # we have non-blank translation text
             localized_json[key] = translation
         else:
             if key in localized_json:
                 # we're deleting the translation, since
                 # the translation text is blank
                 localized_json.pop(key, None)
     return localized_json