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 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. 3
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. 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"
    )
Esempio n. 5
0
from flask import Blueprint, render_template, abort, redirect, request, url_for, g
from os.path import exists,join
from os import listdir
from flask.helpers import safe_join, send_from_directory
from urlparse import urljoin
from website.cache import cache
from website.translation import languages, gettext_docs
from website.utils import Specification, Documentation
from docutils import core

docs = Blueprint("docs",__name__,template_folder="templates",static_folder="static",url_prefix='/<any(%s):lang_code>/docs/<version>' % ",".join(languages))

SOURCES = Documentation(join(docs.root_path,"sources"))

STABLE = SOURCES.get_stable()
DEV = SOURCES.get_dev()

SPECS = Specification(join(docs.root_path,"specs"))

@docs.url_defaults
def add_language_code(endpoint, values):
	values.setdefault('lang_code',g.lang_code)
	if not getattr(g,'version',None) is None:
		values.setdefault('version',g.version)
	else:
		values.setdefault('version',STABLE)

@docs.url_value_preprocessor
def pull_language_code(endpoint, values):
	g.lang_code = values.pop('lang_code')
	g.version = values.pop('version')
Esempio n. 6
0
from os import listdir
from flask.helpers import safe_join, send_from_directory
from urlparse import urljoin
from website.cache import cache
from website.translation import languages, gettext_docs
from website.utils import Specification, Documentation
from docutils import core

docs = Blueprint("docs",
                 __name__,
                 template_folder="templates",
                 static_folder="static",
                 url_prefix='/<any(%s):lang_code>/docs/<version>' %
                 ",".join(languages))

SOURCES = Documentation(join(docs.root_path, "sources"))

STABLE = SOURCES.get_stable()
DEV = SOURCES.get_dev()

SPECS = Specification(join(docs.root_path, "specs"))


@docs.url_defaults
def add_language_code(endpoint, values):
    values.setdefault('lang_code', g.lang_code)
    if not getattr(g, 'version', None) is None:
        values.setdefault('version', g.version)
    else:
        values.setdefault('version', STABLE)