Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/vault.py
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius/vault.py')
-rw-r--r--tutorius/vault.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tutorius/vault.py b/tutorius/vault.py
index 1c1e33c..ef985fa 100644
--- a/tutorius/vault.py
+++ b/tutorius/vault.py
@@ -32,6 +32,7 @@ from ConfigParser import SafeConfigParser
from . import addon
from .tutorial import Tutorial, State, AutomaticTransitionEvent
+from localization import LocalizationHelper
logger = logging.getLogger("tutorius")
@@ -60,6 +61,7 @@ INI_CATEGORY_PROPERTY = 'category'
INI_FILENAME = "meta.ini"
TUTORIAL_FILENAME = "tutorial.xml"
RESOURCES_FOLDER = 'resources'
+LOCALIZATION_FOLDER = 'localization'
######################################################################
# XML Tag names and attributes
@@ -352,6 +354,12 @@ class Vault(object):
with open(ini_file_path, 'wb') as configfile:
parser.write(configfile)
+ l10n_path = os.path.join(tutorial_path, LOCALIZATION_FOLDER)
+ os.mkdir(l10n_path)
+ # Write the localization template (.pot) file
+ with open(os.path.join(l10n_path, 'tutorial_text.pot'), "wb") as l10n_file:
+ LocalizationHelper.write_translation_file(tutorial, l10n_file)
+
else:
# Error, tutorial already exist
return False
@@ -528,6 +536,25 @@ class Vault(object):
else:
return None
+ @staticmethod
+ def get_localization_dir(tutorial_guid):
+ """
+ Returns the base folder under which all the <language>/LC_MESSAGES/tutorial_text.mo
+ are stored. These files are used for runtime translations by the Resource
+ Translator.
+
+ @param tutorial_guid the guid of the tutorial
+ @returns the directory that stores the translation objects
+ """
+ # Get the tutorial path
+ bundler = TutorialBundler(tutorial_guid)
+ tutorial_path = bundler.get_tutorial_path(tutorial_guid)
+ # Check if the localization directory exists
+ l10n_dir = os.path.join(tutorial_path, LOCALIZATION_FOLDER)
+ if os.path.isdir(l10n_dir):
+ return l10n_dir
+ else:
+ return None
class Serializer(object):
"""