Ejemplo n.º 1
0
        /// <summary>
        /// 输出语言包;
        /// </summary>
        public void Serialize(Stream stream, LanguagePackDescription description, LanguageSplitDictionary dictionary)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (dictionary == null)
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            using (ZipOutputStream zipOutputStream = new ZipOutputStream(stream))
            {
                zipOutputStream.IsStreamOwner = false;

                ZipEntry descZipEntry = new ZipEntry(descriptionFileName);
                zipOutputStream.PutNextEntry(descZipEntry);
                descriptionSerializer.Value.Serialize(zipOutputStream, description);

                SplitLanguageCollection collection = Split(dictionary);

                foreach (var value in collection.List)
                {
                    string name         = value.Key + dictionaryFileExtension;
                    var    keyValueList = value.Value;

                    ZipEntry dictionaryZipEntry = new ZipEntry(name);
                    zipOutputStream.PutNextEntry(dictionaryZipEntry);
                    languageListSerializer.Value.Serialize(zipOutputStream, keyValueList);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 序列化语言包内容;
        /// </summary>
        public void Serialize(Stream stream, LanguagePackDescription description, LanguageDictionary dictionary)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (dictionary == null)
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            using (ZipOutputStream zipOutputStream = new ZipOutputStream(stream))
            {
                zipOutputStream.IsStreamOwner = false;

                ZipEntry descZipEntry = new ZipEntry(descriptionFileName);
                zipOutputStream.PutNextEntry(descZipEntry);
                descriptionSerializer.Value.Serialize(zipOutputStream, description);

                const string name = "Main" + dictionaryFileExtension;
                ZipEntry     dictionaryZipEntry = new ZipEntry(name);
                zipOutputStream.PutNextEntry(dictionaryZipEntry);
                dictionarySerializer.Value.Serialize(zipOutputStream, dictionary);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 仅序列化语言包描述;
        /// </summary>
        public void Serialize(Stream stream, LanguagePackDescription description)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (ZipOutputStream zipOutputStream = new ZipOutputStream(stream))
            {
                zipOutputStream.IsStreamOwner = false;

                ZipEntry descZipEntry = new ZipEntry(descriptionFileName);
                zipOutputStream.PutNextEntry(descZipEntry);
                descriptionSerializer.Value.Serialize(zipOutputStream, description);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 序列化语言包内容;
 /// </summary>
 public void Serialize(Stream stream, LanguagePackDescription description, ILanguageDictionary dictionary)
 {
     if (dictionary == null)
     {
         Serialize(stream, description);
     }
     else if (dictionary is LanguageDictionary)
     {
         Serialize(stream, description, dictionary as LanguageDictionary);
     }
     else if (dictionary is LanguageSplitDictionary)
     {
         Serialize(stream, description, dictionary as LanguageSplitDictionary);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Ejemplo n.º 5
0
 public LanguagePack(LanguagePackDescription description, ILanguageDictionary languageDictionary)
 {
     Description        = description;
     LanguageDictionary = languageDictionary;
 }
Ejemplo n.º 6
0
 public LanguagePack(LanguagePackDescription description) : this(description, null)
 {
 }
        /// <summary>
        /// 获取到该模组合适的语言补充包,若不存在则返回null;
        /// </summary>
        private LanguagePackInfo FindSupplementaryPack(LanguagePackSerializer packSerializer, Modification mod, LanguagePackDescription target)
        {
            var supplementaryPackInfo    = packSerializer.EnumerateSupplementaryPack(mod.BaseContent, SearchOption.TopDirectoryOnly);
            LanguagePackInfo defaultInfo = null;

            foreach (var packInfo in supplementaryPackInfo)
            {
                if (packInfo.Description.Language == target.Language)
                {
                    return(packInfo);
                }
                else if (packInfo.Description.IsDefault)
                {
                    defaultInfo = packInfo;
                }
            }

            return(defaultInfo);
        }
        private void DeserializeConfig(LocalizationConfigSerializer configSerializer, LanguagePackDescription description)
        {
            try
            {
                LocalizationConfig config = new LocalizationConfig()
                {
                    Name     = description.Name,
                    Language = description.Language,
                };

                using (Resource.ConfigContent.BeginUpdateAuto())
                {
                    configSerializer.Serialize(Resource.ConfigContent, config);
                }
            }
            catch (Exception ex)
            {
                Debug.LogWarning("输出语言配置失败:" + ex);
            }
        }
Ejemplo n.º 9
0
 private void CheckIsSame(LanguagePackDescription desc1, LanguagePackDescription desc2)
 {
     Assert.AreEqual(desc1.Name, desc2.Name);
     Assert.AreEqual(desc1.Language, desc2.Language);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 指定语言包文件信息;
 /// </summary>
 public LanguagePackInfo(LanguagePackDescription description, Content content, string relativePath)
 {
     Description  = description;
     Content      = content;
     RelativePath = relativePath;
 }