def pull(command_options, args, project_type = None): """ Usage: zanata pull [OPTIONS] {documents} {lang} Retrieve translated publican content files from server Options: --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-type: project type (gettext or podir) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --transdir: translations will be written to this folder --lang: language list (defaults to zanata.xml locales) """ dir_option = False skeletons = True filelist = [] zanatacmd = ZanataCommand() output_folder = None project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) get_version(url) zanata = generate_zanataresource(url, username, apikey) #if file not specified, push all the files in pot folder to zanata server project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) lang_list = get_lang_list(command_options, project_config) #list the files in project try: filelist = zanata.documents.get_file_list(project_id, iteration_id) except Exception, e: log.error(str(e)) sys.exit(1)
def publican_push(command_options, args): """ Usage: zanata publican push OPTIONS {documents} Push publican content to server for translation. Argumensts: documents Options: -f: force to remove content on server side --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --dir: the path of the folder that contains pot folder and locale folders, no need to specify --srcdir and --transdir if --dir option specified --srcdir: the path of the pot folder (e.g. ./pot) --transdir: the path of the folder that contain locale folders (e.g. ./myproject) --import-po: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions --lang: language list """ copytrans = True importpo = False force = False dir_option = False deletefiles = False plural_support = False tmlfolder = "" filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': 'podir'} zanatacmd = ZanataCommand() project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) server_version = get_version(url) plural_support = check_plural_support(server_version) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) tmlfolder = process_srcdir_withsub(command_options, "podir") if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
def po_push(command_options, args): """ Usage: zanata po push [OPTIONS] {documents} Push software project source and translation files to server Options: -f: force to remove content on server side --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --dir: the path of the folder that contains pot files and po files, no need to specify --srcdir and --transdir if --dir option specified --srcdir: the path of the po folder(e.g. ./po) --srcfile: the path of the source file --transdir: the path of the folder that contains po files(e.g. ./po) --import-po: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions --lang: language list """ copytrans = True importpo = False force = False dir_option = False command_type = '' tmlfolder = "" plural_support = False filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': 'gettext'} zanatacmd = ZanataCommand() project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) server_version = get_version(url) plural_support = check_plural_support(server_version) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) if command_options.has_key('srcfile'): tmlfolder, import_file = process_srcfile(command_options) filelist.append(import_file) tmlfolder = process_srcdir_withsub(command_options, "gettext") if not os.path.isdir(tmlfolder): log.error("Can not find source folder, please specify the source folder with '--srcdir' or 'dir' option") sys.exit(1) log.info("PO directory (originals):%s" % tmlfolder) if command_options.has_key('importpo'): importpo = True if command_options.has_key('pushtrans'): log.info("please use --import-po for old publican push command") importpo = True if importpo: log.info("Importing translation") import_param['transdir'] = process_transdir(command_options, tmlfolder) log.info("Reading locale folders from %s" % import_param['transdir']) import_param['merge'] = process_merge(command_options) import_param['lang_list'] = get_lang_list(command_options, project_config) if project_config.has_key('locale_map'): import_param['locale_map'] = project_config['locale_map'] else: import_param['locale_map'] = None importpo = True else: log.info("Importing source documents only") if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
def push(command_options, args, project_type = None): """ Usage: zanata push OPTIONS {documents} Generic push command to push content to server for translation. Argumensts: documents Options: -f: force to remove content on server side --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-type: project type (gettext or podir) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --srcdir: the path of the pot folder (e.g. ./pot) --srcfile: the path of the pot file(gettext project only) --transdir: the path of the folder that contain locale folders (e.g. ./myproject) --push-trans: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions --lang: language list (defaults to zanata.xml locales) """ copytrans = True importpo = False force = False dir_option = False deletefiles = False plural_support = False command_type = '' tmlfolder = "" filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': ''} zanatacmd = ZanataCommand() project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) server_version = get_version(url) plural_support = check_plural_support(server_version) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) if command_options.has_key('project_type'): command_type = command_options['project_type'][0]['value'] elif project_config['project_type']: command_type = project_config['project_type'] else: log.error("The project type is unknown") sys.exit(1) if command_type != 'podir' and command_type != 'gettext': log.error("The project type is not correct, please use 'podir' and 'gettext' as project type") sys.exit(1) if command_options.has_key('srcfile'): if command_type == 'gettext': tmlfolder, import_file = process_srcfile(command_options) filelist.append(import_file) else: log.warn("srcfile option is not used for podir type project, ignored") #Disable dir option for generic push command if command_options.has_key('dir'): log.warn("dir option is disabled in push command, please use --srcdir and --transdir, or specify value in zanata.xml") if command_type != 'podir' and command_type != 'gettext': log.error("The project type is unknown") sys.exit(1) if tmlfolder == "": tmlfolder = process_srcdir(command_options) if not os.path.isdir(tmlfolder): log.error("Can not find source folder, please specify the source folder with '--srcdir' or using zanata.xml") sys.exit(1) if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
def push(command_options, args, project_type = None): """ Usage: zanata push OPTIONS {documents} Generic push command to push content to server for translation. Argumensts: documents Options: -f: force to remove content on server side --username: user name --apikey: api key of user --project-type: project type (software or publican) --project-id: id of the project --project-version: id of the version --srcdir: the full path of the pot folder (e.g. /home/jamesni/myproject/pot) --transdir: the full path of the folder that contain locale folders (e.g. /home/jamesni/myproject) --import-po: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions """ copytrans = True importpo = False force = False command_type = '' tmlfolder = "" filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': ''} zanatacmd = ZanataCommand() project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) get_version(url) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) if command_options.has_key('project_type'): command_type = command_options['project_type'][0]['value'] elif project_type: command_type = project_type else: log.error("The project type is unknown") sys.exit(1) if command_type == 'software' and command_options.has_key('srcfile'): tmlfolder, import_file = process_srcfile(command_options) filelist.append(import_file) else: tmlfolder = process_srcdir(command_options, command_type, project_config) if not os.path.isdir(tmlfolder): log.error("Can not find source folder, please specify the source folder with '--srcdir' or '--dir' option") sys.exit(1) if command_type == 'publican': log.info("POT directory (originals):%s" % tmlfolder) elif command_type == 'software': log.info("PO directory (originals):%s" % tmlfolder) if command_options.has_key('importpo'): log.info("Importing translation") import_param['transdir'] = process_transdir(command_options, project_config) log.info("Reading locale folders from %s" % import_param['transdir']) import_param['merge'] = process_merge(command_options) import_param['lang_list'] = get_lang_list(command_options, project_config) if project_config.has_key('locale_map'): import_param['locale_map'] = project_config['locale_map'] else: import_param['locale_map'] = None import_param['project_type'] = command_type importpo = True else: log.info("Importing source documents only") if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)