コード例 #1
0
        public bool SetLanguage(string languageName)
        {
            if (languageName == CurrentTranslationLanguage || languageName == null)
            {
                return(false);
            }
            if (!LanguageList.Contains(languageName))
            {
                return(false);
            }
            var lng = TranslationSerializer.DecryptData <InterfaceTranslation>(
                Path.Combine(Folder, languageName + _fileExtension), _entropy);

            if (lng == null)
            {
                return(false);
            }
            _alterTranslation          = lng;
            CurrentTranslationLanguage = languageName;
            return(true);
        }
コード例 #2
0
        public void Initialize()
        {
            if (!Directory.Exists(Folder))
            {
                Directory.CreateDirectory(Folder);
            }

            foreach (var item in Directory.GetFiles(Folder))
            {
                if (!CheckForUnprotectedTranslation(item) || !item.Contains(translationExtension))
                {
                    continue;
                }
                var fi = new FileInfo(item);
                LanguageList.Add(fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length));
            }
            if (!LanguageList.Contains("English"))
            {
                var englishUi = new InterfaceTranslation
                {
                    LanguageName = "English",
                    Translation  = GetTranslationTags(GetAllWindows())
                };
                if (_withEncryption)
                {
                    englishUi.CryptData(Path.Combine(Folder, "English" + _fileExtension), _entropy);
                }
                else
                {
                    englishUi.SerializeDataJson(Path.Combine(Folder, "English" + _fileExtension));
                }
                LanguageList.Add("English");
            }

#if DEBUG
            CurrentTranslationLanguage = "EMPTY";
#endif
        }