Esempio n. 1
0
def translate(args):
	if args.update_translation:
		#from website
		_,fname = mkstemp(suffix=".pot")
		os.system("pybabel extract -F website/babel.cfg -o %s website/" % fname)
		os.system("pybabel update -D messages -i %s -d translations/" % fname)
		os.remove(fname)

		#from documentation
		from website.utils import Documentation
		fhandle,fname = mkstemp(suffix=".pot")
		with os.fdopen(fhandle,"w") as fid:
			docs = Documentation(os.path.join(args.repo,'website','docs','sources'))
			docs.extract_messages(fid)
		os.system("pybabel update -D docs -d translations -i %s" % fname)
		os.remove(fname)

		#from parts data
		repo = Repository(args.repo)
		from backends.translations import TranslationBackend
		fhandle,fname = mkstemp(suffix=".pot")
		TranslationBackend(repo,[]).write_output(fname)

		os.system("pybabel update -D parts -d translations -i %s" % fname)
		os.remove(fname)

	if args.compile_translation:
		os.system("pybabel compile -D messages -d translations/")
		os.system("pybabel compile -D parts -d translations/")
		os.system("pybabel compile -D docs -d translations/")
Esempio n. 2
0
def translate(args):
    if args.update_translation:
        # from website
        _, fname = mkstemp(suffix=".pot")
        os.system("pybabel extract -F website/babel.cfg -o %s website/" % fname)
        os.system("pybabel update -D messages -i %s -d translations/" % fname)
        os.remove(fname)

        # from documentation
        from website.utils import Documentation
        fhandle, fname = mkstemp(suffix=".pot")
        with os.fdopen(fhandle, "w") as fid:
            docs = Documentation(os.path.join(args.repo, 'website', 'docs', 'sources'))
            docs.extract_messages(fid)
        os.system("pybabel update -D docs -d translations -i %s" % fname)
        os.remove(fname)

        # from parts data
        repo = Repository(args.repo)
        from backends.translations import TranslationBackend
        fhandle, fname = mkstemp(suffix=".pot")
        TranslationBackend(repo, []).write_output(fname)

        os.system("pybabel update -D parts -d translations -i %s" % fname)
        os.remove(fname)

    if args.compile_translation:
        os.system("pybabel compile -D messages -d translations/")
        os.system("pybabel compile -D parts -d translations/")
        os.system("pybabel compile -D docs -d translations/")
Esempio n. 3
0
def add_lang(args):
	#from website
	_,fname = mkstemp(suffix=".pot")
	os.system("pybabel extract -F website/babel.cfg -o %s website/" % fname)
	os.system("pybabel init -D messages -d translations/ -i %s -l %s" % (fname,args.lang))
	os.remove(fname)

	#from documentation
	from website.utils import Documentation
	fhandle,fname = mkstemp(suffix=".pot")
	with os.fdopen(fhandle,"w") as fid:
		docs = Documentation(os.path.join(args.repo,'website','docs','sources'))
		docs.extract_messages(fid)
	os.system("pybabel init -D docs -d translations/ -i %s -l %s" % (fname,args.lang))
	os.remove(fname)

	#from parts data
	repo = Repository(args.repo)
	from backends.translations import TranslationBackend
	fhandle,fname = mkstemp(suffix=".pot")
	TranslationBackend(repo,[]).write_output(fname)

	os.system("pybabel init -D parts -d translations/ -i %s -l %s" % (fname,args.lang))
	os.remove(fname)
	print("Don't forget to edit website/templates/base.html and add the language to the dropdown menu")
Esempio n. 4
0
def add_lang(args):
    # from website
    _, fname = mkstemp(suffix=".pot")
    os.system("pybabel extract -F website/babel.cfg -o %s website/" % fname)
    os.system("pybabel init -D messages -d translations/ -i %s -l %s" % (fname, args.lang))
    os.remove(fname)

    # from documentation
    from website.utils import Documentation
    fhandle, fname = mkstemp(suffix=".pot")
    with os.fdopen(fhandle, "w") as fid:
        docs = Documentation(os.path.join(args.repo, 'website', 'docs', 'sources'))
        docs.extract_messages(fid)
    os.system("pybabel init -D docs -d translations/ -i %s -l %s" % (fname, args.lang))
    os.remove(fname)

    # from parts data
    repo = Repository(args.repo)
    from backends.translations import TranslationBackend
    fhandle, fname = mkstemp(suffix=".pot")
    TranslationBackend(repo, []).write_output(fname)

    os.system("pybabel init -D parts -d translations/ -i %s -l %s" % (fname, args.lang))
    os.remove(fname)
    print(
        "Don't forget to edit website/templates/base.html "
        "and add the language to the dropdown menu"
    )