Example #1
0
 def test_load_wrong_json_file(self):
     resource_loader.init_json_loader()
     with self.assertRaisesRegexp(I18nFileLoadError,
                                  "error getting data .*"):
         resource_loader.load_resource(
             os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.json"),
             "foo")
Example #2
0
 def test_load_json_file(self):
     resource_loader.init_json_loader()
     data = resource_loader.load_resource(
         os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.json"),
         "settings")
     self.assertIn("foo", data)
     self.assertEqual("bar", data['foo'])
Example #3
0
 def test_load_file_with_strange_encoding(self):
     resource_loader.init_json_loader()
     config.set("encoding", "euc-jp")
     data = resource_loader.load_resource(
         os.path.join(RESOURCE_FOLDER, "settings", "eucjp_config.json"),
         "settings")
     self.assertIn("ほげ", data)
     self.assertEqual("ホゲ", data['ほげ'])
Example #4
0
 def test_skip_locale_root_data_nested_json_dict__other_locale(self):
     config.set("file_format", "json")
     config.set("load_path", [os.path.join(RESOURCE_FOLDER, "translations", "nested_dict_json")])
     config.set("filename_format", "{locale}.{format}")
     config.set('skip_locale_root_data', True)
     config.set("locale", "en")
     resource_loader.init_json_loader()
     self.assertEqual(t('COMMON.EXECUTE', locale="pl"), 'Wykonaj')
Example #5
0
 def test_skip_locale_root_data_nested_json_dict__default_locale(self):
     config.set("file_format", "json")
     config.set("load_path", [os.path.join(RESOURCE_FOLDER, "translations", "nested_dict_json")])
     config.set("filename_format", "{locale}.{format}")
     config.set('skip_locale_root_data', True)
     config.set("locale", "en")
     resource_loader.init_json_loader()
     self.assertEqual(t('COMMON.START'), 'Start')
Example #6
0
 def test_search_translation_without_ns_nested_dict__default_locale(self):
     resource_loader.init_json_loader()
     config.set("file_format", "json")
     config.set("load_path", [
         os.path.join(RESOURCE_FOLDER, "translations", "nested_dict_json")
     ])
     config.set("filename_format", "{locale}.{format}")
     config.set('skip_locale_root_data', True)
     config.set("locale", "en")
     resource_loader.search_translation("TOP_MENU.TOP_BAR.LOGS")
     self.assertTrue(translations.has("TOP_MENU.TOP_BAR.LOGS"))
     self.assertEqual(translations.get("TOP_MENU.TOP_BAR.LOGS"), "Logs")
Example #7
0
 def test_search_translation_without_ns_nested_dict__two_levels_neting__default_locale(
         self):
     resource_loader.init_json_loader()
     config.set("file_format", "json")
     config.set("load_path", [
         os.path.join(RESOURCE_FOLDER, "translations", "nested_dict_json")
     ])
     config.set("filename_format", "{locale}.{format}")
     config.set('skip_locale_root_data', True)
     config.set("locale", ["en", "pl"])
     resource_loader.search_translation("COMMON.VERSION")
     self.assertTrue(translations.has("COMMON.VERSION"))
     self.assertEqual(translations.get("COMMON.VERSION"), "version")
Example #8
0
 def test_search_translation_without_ns(self):
     resource_loader.init_json_loader()
     config.set('file_format', 'json')
     config.set('filename_format', '{locale}.{format}')
     resource_loader.search_translation('foo')
     self.assertTrue(translations.has('foo'))
Example #9
0
    def test_search_translation_json(self):
        resource_loader.init_json_loader()
        config.set('file_format', 'json')

        resource_loader.search_translation('bar.baz.qux')
        self.assertTrue(translations.has('bar.baz.qux'))
Example #10
0
 def test_search_translation_without_ns(self):
     resource_loader.init_json_loader()
     config.set("file_format", "json")
     config.set("filename_format", "{locale}.{format}")
     resource_loader.search_translation("foo")
     self.assertTrue(translations.has("foo"))
Example #11
0
    def test_search_translation_json(self):
        resource_loader.init_json_loader()
        config.set("file_format", "json")

        resource_loader.search_translation("bar.baz.qux")
        self.assertTrue(translations.has("bar.baz.qux"))
Example #12
0
 def test_load_file_with_strange_encoding(self):
     resource_loader.init_json_loader()
     config.set("encoding", "euc-jp")
     data = resource_loader.load_resource(os.path.join(RESOURCE_FOLDER, "settings", "eucjp_config.json"), "settings")
     self.assertIn("ほげ", data)
     self.assertEqual("ホゲ", data['ほげ'])
Example #13
0
 def test_load_json_file(self):
     resource_loader.init_json_loader()
     data = resource_loader.load_resource(os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.json"), "settings")
     self.assertIn("foo", data)
     self.assertEqual("bar", data['foo'])
Example #14
0
 def test_load_wrong_json_file(self):
     resource_loader.init_json_loader()
     with self.assertRaisesRegexp(I18nFileLoadError, "error getting data .*"):
         resource_loader.load_resource(os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.json"), "foo")
Example #15
0
 def test_search_translation_without_ns(self):
     resource_loader.init_json_loader()
     config.set('file_format', 'json')
     config.set('filename_format', '{locale}.{format}')
     resource_loader.search_translation('foo')
     self.assertTrue(translations.has('foo'))
Example #16
0
    def test_search_translation_json(self):
        resource_loader.init_json_loader()
        config.set('file_format', 'json')

        resource_loader.search_translation('bar.baz.qux')
        self.assertTrue(translations.has('bar.baz.qux'))