mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Added changelog to the translatable documentation
This commit is contained in:
parent
b3451e229d
commit
7a2e51ef03
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,4 +18,5 @@ src/launcher.bat
|
|||||||
src/sounds/iOs
|
src/sounds/iOs
|
||||||
release-snapshot/
|
release-snapshot/
|
||||||
src/com_cache/
|
src/com_cache/
|
||||||
doc/strings.py
|
doc/strings.py
|
||||||
|
doc/changelog.py
|
@ -2,7 +2,7 @@
|
|||||||
""" This script converts the hold documentation (saved in markdown files) in a python file with a list of strings to translate it using gettext."""
|
""" This script converts the hold documentation (saved in markdown files) in a python file with a list of strings to translate it using gettext."""
|
||||||
|
|
||||||
def prepare_documentation_in_file(fileSource, fileDest):
|
def prepare_documentation_in_file(fileSource, fileDest):
|
||||||
""" This takes documentation written in a markdown file and put all the contents in a python file, to create a internationalized documentation.
|
""" This takes documentation written in a markdown file and put all the contents in a python file, to create a translatable documentation.
|
||||||
@fileSource str: A markdown(.md) file.
|
@fileSource str: A markdown(.md) file.
|
||||||
@fileDest str: A file where this will put the new strings"""
|
@fileDest str: A file where this will put the new strings"""
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ def prepare_documentation_in_file(fileSource, fileDest):
|
|||||||
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i[:-1])
|
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i[:-1])
|
||||||
else:
|
else:
|
||||||
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i)
|
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i)
|
||||||
# print i[-1:]
|
|
||||||
f2.write(newvar)
|
f2.write(newvar)
|
||||||
f1.close()
|
f1.close()
|
||||||
f2.write("]")
|
f2.write("]")
|
||||||
f2.close()
|
f2.close()
|
||||||
|
|
||||||
|
|
||||||
prepare_documentation_in_file("manual.md", "strings.py")
|
prepare_documentation_in_file("manual.md", "strings.py")
|
||||||
|
prepare_documentation_in_file("changelog.md", "changelog.py")
|
@ -5,16 +5,28 @@ from codecs import open as _open
|
|||||||
import languageHandler
|
import languageHandler
|
||||||
languageHandler.setLanguage("en")
|
languageHandler.setLanguage("en")
|
||||||
import strings
|
import strings
|
||||||
|
import changelog
|
||||||
|
|
||||||
# the list of supported language codes of TW Blue
|
# the list of supported language codes of TW Blue
|
||||||
languages = ["en", "es", "fr", "de", "it", "gl", "ja", "ru", "ro"]
|
languages = ["en", "es", "fr", "de", "it", "gl", "ja", "ru", "ro"]
|
||||||
#"eu", "ar", "ca", "es", "fi", "fr", "gl", "hu", "it", "pl", "pt", "ru", "tr"]
|
#"eu", "ar", "ca", "es", "fi", "fr", "gl", "hu", "it", "pl", "pt", "ru", "tr"]
|
||||||
|
|
||||||
def generate_document(language):
|
def generate_document(language, document_type="documentation"):
|
||||||
reload(languageHandler)
|
reload(languageHandler)
|
||||||
languageHandler.setLanguage(language)
|
if document_type == "documentation":
|
||||||
reload(strings)
|
translation_file = "twblue-documentation"
|
||||||
markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"])
|
languageHandler.setLanguage(language, translation_file)
|
||||||
|
reload(strings)
|
||||||
|
markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"])
|
||||||
|
title = strings.documentation[0]
|
||||||
|
filename = "manual.html"
|
||||||
|
elif document_type == "changelog":
|
||||||
|
translation_file = "twblue-changelog"
|
||||||
|
languageHandler.setLanguage(language, translation_file)
|
||||||
|
reload(changelog)
|
||||||
|
markdown_file = markdown.markdown("\n".join(changelog.documentation[1:]), extensions=["markdown.extensions.toc"])
|
||||||
|
title = changelog.documentation[0]
|
||||||
|
filename = "changelog.html"
|
||||||
first_html_block = """<!doctype html>
|
first_html_block = """<!doctype html>
|
||||||
<html lang="%s">
|
<html lang="%s">
|
||||||
<head>
|
<head>
|
||||||
@ -23,12 +35,12 @@ def generate_document(language):
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header><h1>%s</h1></header>
|
<header><h1>%s</h1></header>
|
||||||
""" % (language, strings.documentation[0], strings.documentation[0])
|
""" % (language, title, title)
|
||||||
first_html_block = first_html_block+ markdown_file
|
first_html_block = first_html_block+ markdown_file
|
||||||
first_html_block = first_html_block + "\n</body>\n</html>"
|
first_html_block = first_html_block + "\n</body>\n</html>"
|
||||||
if not os.path.exists(language):
|
if not os.path.exists(language):
|
||||||
os.mkdir(language)
|
os.mkdir(language)
|
||||||
mdfile = _open("%s/manual.html" % language, "w", encoding="utf-8")
|
mdfile = _open("%s/%s" % (language, filename), "w", encoding="utf-8")
|
||||||
mdfile.write(first_html_block)
|
mdfile.write(first_html_block)
|
||||||
mdfile.close()
|
mdfile.close()
|
||||||
|
|
||||||
@ -37,6 +49,7 @@ def create_documentation():
|
|||||||
for i in languages:
|
for i in languages:
|
||||||
print("Creating documentation for: %s" % (i,))
|
print("Creating documentation for: %s" % (i,))
|
||||||
generate_document(i)
|
generate_document(i)
|
||||||
|
generate_document(i, "changelog")
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
||||||
create_documentation()
|
create_documentation()
|
@ -117,7 +117,7 @@ def makePgettext(translations):
|
|||||||
return unicode(message)
|
return unicode(message)
|
||||||
return pgettext
|
return pgettext
|
||||||
|
|
||||||
def setLanguage(lang):
|
def setLanguage(lang, translation_file="twblue-documentation"):
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
global curLang
|
global curLang
|
||||||
try:
|
try:
|
||||||
@ -127,10 +127,10 @@ def setLanguage(lang):
|
|||||||
localeName=locale.windows_locale[windowsLCID]
|
localeName=locale.windows_locale[windowsLCID]
|
||||||
else:
|
else:
|
||||||
localeName=locale.getlocale()[0]
|
localeName=locale.getlocale()[0]
|
||||||
trans=gettext.translation('twblue-documentation', localedir="locales", languages=[localeName])
|
trans=gettext.translation(translation_file, localedir="locales", languages=[localeName])
|
||||||
curLang=localeName
|
curLang=localeName
|
||||||
else:
|
else:
|
||||||
trans=gettext.translation("twblue-documentation", localedir="locales", languages=[lang])
|
trans=gettext.translation(translation_file, localedir="locales", languages=[lang])
|
||||||
curLang=lang
|
curLang=lang
|
||||||
localeChanged=False
|
localeChanged=False
|
||||||
#Try setting Python's locale to lang
|
#Try setting Python's locale to lang
|
||||||
@ -150,7 +150,7 @@ def setLanguage(lang):
|
|||||||
LCID=localeNameToWindowsLCID(lang)
|
LCID=localeNameToWindowsLCID(lang)
|
||||||
ctypes.windll.kernel32.SetThreadLocale(LCID)
|
ctypes.windll.kernel32.SetThreadLocale(LCID)
|
||||||
except IOError:
|
except IOError:
|
||||||
trans=gettext.translation("twblue-documentation",fallback=True)
|
trans=gettext.translation(translation_file,fallback=True)
|
||||||
curLang="en"
|
curLang="en"
|
||||||
trans.install(unicode=True)
|
trans.install(unicode=True)
|
||||||
# Install our pgettext function.
|
# Install our pgettext function.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
echo Generating application translation strings...
|
echo Generating application translation strings...
|
||||||
C:\python27\python.exe pygettext.py -d twblue ../src/*.pyw ../src/*.py ../src/*/*.py ../src/*/*.pyw ../src/*/*/*.py ../src/*/*/*.pyw ../src/*/*/*/*.py ../src/*/*/*/*.pyw ../src/*/*/*/*/*.py ../src/*/*/*/*/*.pyw
|
C:\python27\python.exe pygettext.py -d twblue ../src/*.pyw ../src/*.py ../src/*/*.py ../src/*/*.pyw ../src/*/*/*.py ../src/*/*/*.pyw ../src/*/*/*/*.py ../src/*/*/*/*.pyw ../src/*/*/*/*/*.py ../src/*/*/*/*/*.pyw
|
||||||
C:\python27\python.exe pygettext.py -v -d twblue-documentation ../doc/*.py
|
C:\python27\python.exe pygettext.py -v -d twblue-documentation ../doc/strings.py
|
||||||
|
C:\python27\python.exe pygettext.py -v -d twblue-changelog ../doc/changelog.py
|
Loading…
Reference in New Issue
Block a user