Example #1
0
    def testReadPropertiesComesFromCache(self):
        """
        Do an initial read from Java properties file, delete the file and verify that property reads still work because
        they are served from the cache
        """
        tmp_json = tempfile.NamedTemporaryFile(mode='w', prefix='defaults', suffix='_en.properties', delete=False)
        fullname = tmp_json.name
        tmp_json.close()
        tmppath = os.path.dirname(fullname)
        name = os.path.basename(fullname)
        prefix = name.replace('_en.properties', '')

        # make a copy of a properties file
        copyFile(os.path.join(self.resources_path, 'defaults_en.properties'), fullname)

        # read a value from the properties file
        options = i18n.read_text_options(tmppath, prefix, "en", "attractAttention", "/")
        self.assertTrue(options, "attractAttention should be found")
        self.assertTrue(len(options) > 0, "attractAttention should have at least one option")

        # delete the temp file
        os.remove(fullname)

        # check read of different property from same file still works
        value = i18n.get_property(tmppath, prefix, "en", "hello")
        self.assertTrue(len(value), "hello should be found")
Example #2
0
def localized_text(property_name):
    global resource_dir
    global language_code
    lt = i18n.get_property(resource_dir,
                            'naorecorder',
                            language_code,
                            property_name)
    core_logger.debug("Property '{name}' resolved to text '{value}' in language '{lang}'"
                      .format(name=property_name, value=lt, lang=language_code))
    return lt
Example #3
0
 def testLoadPropertiesChinese(self):
     hello_value = i18n.get_property(self.resources_path, "defaults", "zh",
                                     "hello")
     self.assertEquals("你好", hello_value)
Example #4
0
 def testLoadPropertiesFrench(self):
     hello_value = i18n.get_property(self.resources_path, "defaults", "fr",
                                     "hello")
     self.assertEquals("Bonjour", hello_value)
Example #5
0
 def testLoadPropertiesEnglish(self):
     hello_value = i18n.get_property(self.resources_path, "defaults", "en",
                                     "hello")
     self.assertEquals("Hello", hello_value)
Example #6
0
 def testLoadPropertiesChinese(self):
     hello_value = i18n.get_property(self.resources_path, "defaults", "zh", "hello")
     self.assertEquals("你好", hello_value)
Example #7
0
 def testLoadPropertiesFrench(self):
     hello_value = i18n.get_property(self.resources_path, "defaults", "fr", "hello")
     self.assertEquals("Bonjour", hello_value)
Example #8
0
 def testLoadPropertiesEnglish(self):
     hello_value = i18n.get_property(self.resources_path, "defaults", "en", "hello")
     self.assertEquals("Hello", hello_value)