def createNewTranslation(self, localeStr): translation = self._findTranslation(localeStr) if translation is not None: return translation locale = ZLocale(localeStr) translation = ZTranslation(locale, self.bundleDirectory) self.translations.append(translation) translation.save(self.defaultTranslation) return translation
def getFlagBitmapForLocale(locale): u"""getFlagBitmapForLocale(string|ZLocale) -> wx.Bitmap Gets the flag bitmap for the given ZLocale or locale string.""" #$NON-NLS-1$ if not isinstance(locale, ZLocale): locale = ZLocale(locale) bitmap = None if locale.hasCountryCode(): bitmap = getResourceRegistry().getBitmap(u"images/common/flags/%s.png" % string.lower(locale.getCountryCode())) #$NON-NLS-1$ if bitmap is None: bitmap = getResourceRegistry().getBitmap(u"images/common/flags/%s.png" % locale.getLanguageCode()) #$NON-NLS-1$ return bitmap
def getFlagPathForLocale(localeStr): u"""getFlagPathForLocale(string) -> string Gets the flag bitmap path for the given locale.""" #$NON-NLS-1$ locale = ZLocale(localeStr) bitmapPath = None if locale.hasCountryCode(): bitmapPath = getResourceRegistry().getImagePath(u"images/common/flags/%s.png" % string.lower(locale.getCountryCode())) #$NON-NLS-1$ if bitmapPath is None or not os.path.isfile(bitmapPath): bitmapPath = getResourceRegistry().getImagePath(u"images/common/flags/%s.png" % locale.getLanguageCode()) #$NON-NLS-1$ if bitmapPath is None or not os.path.isfile(bitmapPath): bitmapPath = None return bitmapPath
def _loadTranslations(self, bundleDirectory): def filterFunc(fileName): fileName = os.path.basename(fileName) return fileName.startswith(u"zoundry.base_") #$NON-NLS-1$ # end filterFunc() rval = ZSortedList(self) for bundleFileName in getDirectoryListing(bundleDirectory, filterFunc, False): localeString = self._extractLocale(bundleFileName) locale = ZLocale(localeString) translation = ZTranslation(locale, bundleDirectory) translation.load() rval.append(translation) return rval