Exemple #1
0
 def translate_troop(self, troop, lang):
     troop['name'] = _(troop['name'], lang)
     troop['description'] = _(troop['description'], lang).replace('widerbeleben',
                                                                  'wiederbeleben')
     troop['color_code'] = "".join(troop['colors'])
     troop['rarity_title'] = _('[RARITY]', lang)
     troop['raw_rarity'] = troop['rarity']
     rarity_number = 1
     if troop['rarity'] in TROOP_RARITIES:
         rarity_number = TROOP_RARITIES.index(troop['rarity'])
     troop['rarity'] = _(f'[RARITY_{rarity_number}]', lang)
     troop['traits_title'] = _('[TRAITS]', lang)
     troop['traits'] = self.enrich_traits(troop['traits'], lang)
     troop['roles_title'] = _('[TROOP_ROLE]', lang)
     troop['roles'] = [_(f'[TROOP_ROLE_{role.upper()}]', lang) for role in troop['roles']]
     troop['type_title'] = _('[FILTER_TROOPTYPE]', lang)
     troop['raw_types'] = troop['types']
     types = [
         _(f'[TROOPTYPE_{_type.upper()}]', lang) for _type in troop['types']
     ]
     troop['type'] = ' / '.join(types)
     troop['kingdom_title'] = _('[KINGDOM]', lang)
     troop['kingdom'] = _(troop['kingdom']['Name'], lang)
     troop['spell'] = self.translate_spell(troop['spell_id'], lang)
     troop['spell_title'] = _('[TROOPHELP_SPELL0]', lang)
Exemple #2
0
    def translate_spoiler(self, spoiler, lang):
        entry = getattr(self, spoiler['type'] + 's').get(spoiler['id'],
                                                         {}).copy()
        if not entry:
            return None
        entry['name'] = _(entry['name'], lang)
        if self.is_untranslated(entry['name']):
            entry['name'] = entry.get('reference_name', entry['name'])
        entry['type'] = spoiler['type']
        entry['date'] = spoiler['date'].date()
        entry['event'] = _('[GLOG_EVENT]',
                           lang) + ': ' if entry.get('event') else ''
        if 'rarity' in entry:
            entry['rarity_title'] = _('[RARITY]', lang)
            if entry['rarity'] in TROOP_RARITIES:
                rarity_number = TROOP_RARITIES.index(entry['rarity'])
                entry['rarity'] = _(f'[RARITY_{rarity_number}]', lang)

        kingdom_id = entry.get('kingdom_id')
        if kingdom_id:
            kingdom = self.kingdoms[kingdom_id]
            entry['kingdom'] = _(kingdom['name'], lang)
            if self.is_untranslated(entry['kingdom']):
                entry['kingdom'] = kingdom['reference_name']
        return entry
Exemple #3
0
    def translate_spoiler(self, spoiler, lang):
        # FIXME this is transitional until all new models are in place.
        if spoiler['type'] in ['pet']:
            item = getattr(self, spoiler['type'] + 's').get(spoiler['id'])
            if not item:
                return
            entry = item[translations.LANGUAGE_CODE_MAPPING.get(
                lang, lang)].data.copy()
        else:
            entry = getattr(self,
                            spoiler['type'] + 's').get(spoiler['id'],
                                                       {}).copy()
        if not entry:
            return None
        entry['name'] = _(entry['name'], lang)
        if self.is_untranslated(entry['name']):
            entry['name'] = entry.get('reference_name', entry['name'])
        entry['type'] = spoiler['type']
        entry['date'] = spoiler['date'].date()
        entry['event'] = _('[GLOG_EVENT]',
                           lang) + ': ' if entry.get('event') else ''
        if 'rarity' in entry:
            entry['rarity_title'] = _('[RARITY]', lang)
            if entry['rarity'] in TROOP_RARITIES:
                rarity_number = TROOP_RARITIES.index(entry['rarity'])
                entry['rarity'] = _(f'[RARITY_{rarity_number}]', lang)

        kingdom_id = entry.get('kingdom_id')
        if kingdom_id:
            kingdom = self.kingdoms[kingdom_id]
            entry['kingdom'] = _(kingdom['name'], lang)
            if self.is_untranslated(entry['kingdom']):
                entry['kingdom'] = kingdom['reference_name']
        return entry
Exemple #4
0
    def translate_spoiler(self, spoiler, lang):
        entry = getattr(self, spoiler['type'] + 's').get(spoiler['id'], {}).copy()
        entry['name'] = _(entry['name'], lang)
        entry['type'] = spoiler['type']
        entry['date'] = spoiler['date']
        if 'rarity' in entry:
            entry['rarity_title'] = _('[RARITY]', lang)
            if entry['rarity'] in TROOP_RARITIES:
                rarity_number = TROOP_RARITIES.index(entry['rarity'])
                entry['rarity'] = _(f'[RARITY_{rarity_number}]', lang)

        kingdom_id = entry.get('kingdom_id')
        if kingdom_id:
            kingdom = self.kingdoms[kingdom_id]
            entry['kingdom'] = _(kingdom['name'], lang)
        return entry
Exemple #5
0
 def translate_troop(self, troop, lang):
     troop['name'] = _(troop['name'], lang)
     if self.is_untranslated(troop['name']):
         troop['name'] = troop['reference_name']
     troop['description'] = _(troop['description'],
                              lang).replace('widerbeleben', 'wiederbeleben')
     troop['color_code'] = "".join(troop['colors'])
     troop['rarity_title'] = _('[RARITY]', lang)
     troop['raw_rarity'] = troop['rarity']
     rarity_number = 1
     if troop['rarity'] in TROOP_RARITIES:
         rarity_number = TROOP_RARITIES.index(troop['rarity'])
     troop['rarity'] = _(f'[RARITY_{rarity_number}]', lang)
     troop['traits_title'] = _('[TRAITS]', lang)
     troop['traits'] = self.enrich_traits(troop['traits'], lang)
     troop['roles_title'] = _('[TROOP_ROLE]', lang)
     troop['roles'] = [
         _(f'[TROOP_ROLE_{role.upper()}]', lang) for role in troop['roles']
     ]
     troop['type_title'] = _('[FILTER_TROOPTYPE]', lang)
     troop['raw_types'] = troop['types']
     types = [
         _(f'[TROOPTYPE_{_type.upper()}]', lang) for _type in troop['types']
     ]
     troop['type'] = ' / '.join(types)
     troop['kingdom_title'] = _('[KINGDOM]', lang)
     reference_name = troop['kingdom'].get('reference_name',
                                           troop['kingdom']['name'])
     troop['kingdom'] = _(troop['kingdom']['name'], lang)
     if self.is_untranslated(troop['kingdom']):
         troop['kingdom'] = reference_name
     troop['spell'] = self.translate_spell(troop['spell_id'], lang)
     troop['spell_title'] = _('[TROOPHELP_SPELL0]', lang)
     troop['traitstones_title'] = _('[SOULFORGE_TAB_TRAITSTONES]', lang)
     if 'traitstones' not in troop:
         troop['traitstones'] = []
     traitstones = []
     for rune in troop['traitstones']:
         traitstones.append(f'{_(rune["name"], lang)} ({rune["amount"]})')
     troop['traitstones'] = traitstones
     troop['bonuses_title'] = _('[BONUSES]', lang)
Exemple #6
0
 def convert_rarity(self):
     rarity_number = 1
     if self.raw_data['TroopRarity'] in TROOP_RARITIES:
         rarity_number = TROOP_RARITIES.index(self.raw_data['TroopRarity'])
     return f'[RARITY_{rarity_number}]'