diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-11-30 16:51:15 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-12-05 21:17:50 (GMT) |
commit | d9eb3274aaa6e1395c86c4dfaa488e493969857b (patch) | |
tree | 9231c0a18eb8b9efa2decb274f5a6d7c0f2ce59e /tutorius/vault.py | |
parent | 32c62b4f0370791eb52e4ee8f9c0f1ee3058675d (diff) |
LP 448319 : Translation layer tests and automatic generation of pot file (ongoing)
Diffstat (limited to 'tutorius/vault.py')
-rw-r--r-- | tutorius/vault.py | 27 |
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): """ |