Beispiel #1
0
        public void ImportTest()
        {
            var importer = new XliffImporter();
            var xml      = new XmlDocument();

            xml.LoadXml(TestData);
            var holder = new LocalizedLanguageHolder();

            importer.Import(xml, holder);

            // check if the simple entry works for all languages
            Assert.AreEqual("Hello world", holder.GetData("hi", "en"));
            Assert.AreEqual("Bonjour le monde", holder.GetData("hi", "fr"));
            Assert.AreEqual("Hola mundo", holder.GetData("hi", "es"));
            Assert.AreEqual("Ciao mondo", holder.GetData("hi", "it"));
            Assert.AreEqual("Hallo Welt", holder.GetData("hi", "de"));

            // check if the groups work
            Assert.AreEqual("Hello world", holder.GetData("group1.hi", "en"));
            Assert.AreEqual("Bonjour le monde", holder.GetData("group1.hi", "fr"));
            Assert.AreEqual(null, holder.GetData("group1.hi", "es"));
            Assert.AreEqual(null, holder.GetData("group1.hi", "it"));
            Assert.AreEqual(null, holder.GetData("group1.hi", "de"));

            // check if nested groups work
            Assert.AreEqual("Hello world", holder.GetData("group1.groupInGroup1.hi", "en"));
            Assert.AreEqual("Bonjour le monde", holder.GetData("group1.groupInGroup1.hi", "fr"));
        }
        protected void LoadL10NData()
        {
            var importer = new XliffImporter();
            var xml      = new XmlDocument();
            var xliff    = Resources.Load("L10N/default.xliff") as TextAsset;

            xml.LoadXml(xliff.text);
            importer.Import(xml, (LocalizedLanguageHolder)L10N);
        }