コード例 #1
0
    def GetShortcutAsString(self):
        if not self.shortcut:
            return ''
        retString = ''
        for key in self.shortcut:
            import trinity
            newKey = trinity.app.GetKeyNameText(key)
            if not newKey:
                newKey = ', '.join([
                    each[3:] for each in dir(uiconst)
                    if each.startswith('VK_') and getattr(uiconst, each) == key
                ])
                newKey = RENAMEMAP.get(newKey, newKey)
            retString += '%s-' % newKey

        retString = retString[:-1]
        import localizationInternalUtil
        retString = localizationInternalUtil.PrepareLocalizationSafeString(
            retString, messageID='commandShortcut')
        try:
            retString.decode('cp1252')
        except UnicodeDecodeError:
            retString = '???'

        return retString
コード例 #2
0
def FormatDateTime(value, **kwargs):
    formatStringList = []
    if kwargs.get('dateFormat',
                  'short') in ('full', 'long', 'medium', 'short'):
        formatStringList.append('%Y.%m.%d')
    timeFormat = kwargs.get('timeFormat', 'short')
    if timeFormat in ('full', 'long', 'medium'):
        formatStringList.append('%H:%M:%S')
    elif timeFormat == 'short':
        formatStringList.append('%H:%M')
    formatString = ' '.join(formatStringList)
    if isinstance(value, long):
        value = value + eveLocalization.GetTimeDelta() * const.SEC
        year, month, weekday, day, hour, minute, second, msec = blue.os.GetTimeParts(
            value)
        day_of_year = 1
        is_daylight_savings = -1
        value = (year, month, day, hour, minute, second, weekday, day_of_year,
                 is_daylight_savings)
    elif isinstance(value, (time.struct_time, tuple)):
        value = calendar.timegm(value)
        value = time.gmtime(value + eveLocalization.GetTimeDelta())
    elif isinstance(value, float):
        value = time.gmtime(value + eveLocalization.GetTimeDelta())
    else:
        localization.LogError(
            'datetime only accepts blue time or Python time as values, but we received a ',
            type(value).__name__, '.')
        return None
    return localizationInternalUtil.PrepareLocalizationSafeString(
        time.strftime(formatString, value), 'time')
コード例 #3
0
def FormatGenericList(iterable, languageID=None):
    if languageID is not None:
        languageID = localizationInternalUtil.StandardizeLanguageID(languageID)
    if languageID is None:
        languageID = GetLanguageID()
    delimiterDict = {'en-us': u', ', 'ja': u'\u3001', 'zh-cn': u'\uff0c'}
    stringList = [unicode(each) for each in iterable]
    delimeter = delimiterDict.get(languageID, delimiterDict['en-us'])
    return localizationInternalUtil.PrepareLocalizationSafeString(
        delimeter.join(stringList), messageID='genericlist')
コード例 #4
0
 def GetMetaData(self, messageID, propertyName, languageID=None):
     languageID = localizationInternalUtil.StandardizeLanguageID(
         languageID) or localizationUtil.GetLanguageID()
     propertyString = self._GetMetaData(messageID, propertyName, languageID)
     if propertyString is not None:
         return localizationInternalUtil.PrepareLocalizationSafeString(
             propertyString, messageID=messageID)
     LogError(
         'a non existent property was requested. messageID,propertyName,languageID : %s,%s,%s'
         % (messageID, propertyName, languageID))
     return '[no property:%s,%s]' % (messageID, propertyName)
コード例 #5
0
def FormatNumeric(value,
                  useGrouping=False,
                  decimalPlaces=None,
                  leadingZeroes=None):
    result = eveLocalization.FormatNumeric(value,
                                           GetLanguageID(),
                                           useGrouping=useGrouping,
                                           decimalPlaces=decimalPlaces,
                                           leadingZeroes=leadingZeroes)
    return localizationInternalUtil.PrepareLocalizationSafeString(
        result, messageID='numeric')
コード例 #6
0
def FormatGenericList(iterable, languageID=None, useConjunction=False):
    languageID = localizationInternalUtil.StandardizeLanguageID(
        languageID) or localizationUtil.GetLanguageID()
    stringList = [unicode(each) for each in iterable]
    delimiter = localization.GetByLabel(
        'UI/Common/Formatting/ListGenericDelimiter')
    if not useConjunction or len(stringList) < 2:
        listString = delimiter.join(stringList)
    elif len(stringList) == 2:
        listString = localization.GetByLabel(
            'UI/Common/Formatting/SimpleGenericConjunction',
            A=stringList[0],
            B=stringList[1])
    else:
        listPart = delimiter.join(stringList[:-1])
        listString = localization.GetByLabel(
            'UI/Common/Formatting/ListGenericConjunction',
            list=listPart,
            lastItem=stringList[-1])
    return localizationInternalUtil.PrepareLocalizationSafeString(
        listString, messageID='genericlist')
コード例 #7
0
 def GetByMessageID(self, messageID, languageID=None, **kwargs):
     if messageID is None:
         return ''
     if languageID is not None:
         languageID = localizationInternalUtil.StandardizeLanguageID(
             languageID)
     if languageID is None:
         languageID = localizationUtil.GetLanguageID()
     if session and 'player' not in kwargs:
         kwargs['player'] = session.charid
     try:
         textString = self._GetByMessageID(messageID, languageID, **kwargs)
         return localizationInternalUtil.PrepareLocalizationSafeString(
             textString, messageID=messageID)
     except KeyError:
         log.LogException()
         return u'[no messageID: %s]' % messageID
     except:
         log.LogException()
         try:
             return self._GetRawByMessageID(messageID)
         except:
             return u'[no messageID: %s]' % messageID
コード例 #8
0
 def _PrepareLocalizationSafeString(self, textString, messageID=None):
     return localizationInternalUtil.PrepareLocalizationSafeString(
         textString, messageID=messageID)