def showDescriptions(baseDir, scriptName, opts, args, type): locales = None for option, value in opts: if option in ('-l', '--locales'): locales = value.split(',') import buildtools.packagerGecko as packager if locales == None: locales = packager.getLocales(baseDir) elif locales == 'all': locales = packager.getLocales(baseDir, True) data = packager.readLocaleMetadata(baseDir, locales) localeCodes = data.keys() localeCodes.sort() for localeCode in localeCodes: locale = data[localeCode] print ('''%s %s %s %s %s ''' % (localeCode, locale['name'] if 'name' in locale else 'None', locale['description'] if 'description' in locale else 'None', locale['description.short'] if 'description.short' in locale else 'None', locale['description.long'] if 'description.long' in locale else 'None', )).encode('utf-8')
def uploadTranslations(baseDir, scriptName, opts, args, type): if len(args) < 1: print 'Project key is required to upload existing translations.' usage(scriptName, type, 'uploadtrans') return key = args[0] if type == 'chrome' or type == 'opera': import buildtools.packagerChrome as packager localesDir = os.path.join(baseDir, '_locales') locales = os.listdir(localesDir) locales = map(lambda locale: (locale.replace('_', '-'), os.path.join(localesDir, locale)), locales) metadata = packager.readMetadata(baseDir, type) basename = metadata.get('general', 'basename') else: import buildtools.packagerGecko as packager localesDir = packager.getLocalesDir(baseDir) locales = packager.getLocales(baseDir, True) locales = map(lambda locale: (locale, os.path.join(localesDir, locale)), locales) metadata = packager.readMetadata(baseDir, type) basename = metadata.get('general', 'basename') import buildtools.localeTools as localeTools for locale, localeDir in locales: if locale != packager.defaultLocale: localeTools.uploadTranslations(type, metadata, localeDir, locale, basename, key)
def setupTranslations(baseDir, scriptName, opts, args, type): if len(args) < 1: print 'Project key is required to update translation master files.' usage(scriptName, type, 'setuptrans') return key = args[0] if type == 'chrome' or type == 'opera': import buildtools.packagerChrome as packager locales = os.listdir(os.path.join(baseDir, '_locales')) locales = map(lambda locale: locale.replace('_', '-'), locales) basename = packager.readMetadata(baseDir, type).get('general', 'basename') else: import buildtools.packagerGecko as packager locales = packager.getLocales(baseDir, True) basename = packager.readMetadata(baseDir, type).get('general', 'basename') import buildtools.localeTools as localeTools localeTools.setupTranslations(type, locales, basename, key)