def test_set_active_bundle_name(self): # Verifies that get_localized and get_rendered are properly affected # by set_active_bundle_name. self.put_resource('1', 'xyz', 0, 'one') self.put_resource('2', 'xyz', 0, 'two') assert resources.get_localized('xyz', 'en').content == 'one' assert resources.get_rendered('xyz', 'en') == 'one' resources.set_active_bundle_name('2') assert resources.get_localized('xyz', 'en').content == 'two' assert resources.get_rendered('xyz', 'en') == 'two' resources.set_active_bundle_name('1') assert resources.get_localized('xyz', 'en').content == 'one' assert resources.get_rendered('xyz', 'en') == 'one'
def test_set_active_bundle_name(self): # Verifies that get_localized and get_rendered are properly affected # by set_active_bundle_name. self.put_resource("1", "xyz", 0, "one") self.put_resource("2", "xyz", 0, "two") assert resources.get_localized("xyz", "en").content == "one" assert resources.get_rendered("xyz", "en") == "one" resources.set_active_bundle_name("2") assert resources.get_localized("xyz", "en").content == "two" assert resources.get_rendered("xyz", "en") == "two" resources.set_active_bundle_name("1") assert resources.get_localized("xyz", "en").content == "one" assert resources.get_rendered("xyz", "en") == "one"
def load_template(self, name, dirs): import resources lang = django.utils.translation.get_language() # currently active lang resource = resources.get_localized(name, lang) template = resource and resource.get_template() if template: return template, name + ':' + lang else: raise django.template.TemplateDoesNotExist(name)
def get_template(self, name, template_dirs=None, skip=None): import resources lang = django.utils.translation.get_language() # currently active lang resource = resources.get_localized(name, lang) template = resource and resource.get_template() if template: return template else: raise django.template.TemplateDoesNotExist(name)