Пример #1
0
 public void CreateLocalizations(ILocalStrings[] localStrings)
 {
     EnsureDefaultLanguageFolder();
     foreach (var localString in localStrings)
     {
         CreateDefaultLocalFile(localString);
     }
 }
Пример #2
0
        public void LoadLocalizations(ILocalStrings[] localStrings)
        {
            _localStrings = localStrings;
            var appRootFolder = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(LocalCreator)).Location)).Parent.FullName;
            _languageFolderPath = Path.Combine(appRootFolder, LANGUAGEFOLDER);
            _localizationFiles = Directory.GetFiles(_languageFolderPath);

            ParseLocalizations();
        }
Пример #3
0
 private void ParseLocalization(ILocalStrings localStrings)
 {
     var loadedStrings = ParseLocalizationFile(localStrings.DisplayName);
     foreach (var loadedString in loadedStrings)
     {
         if (LocalizationStringExists(localStrings, loadedString.Key))
         {
             SetLocalizationString(localStrings, loadedString.Key, loadedString.Value);
         }
     }
 }
Пример #4
0
 private string GetFileContent(ILocalStrings localString)
 {
     var defaultLocalFile = string.Empty;
     foreach (var property in localString.GetType().GetProperties())
     {
         if (property.Name != "DisplayName")
         {
             defaultLocalFile += string.Format("{0} = {1}\n", property.Name, property.GetValue(localString, null));
         }
     }
     return defaultLocalFile;
 }
Пример #5
0
        private void ParseLocalization(ILocalStrings localStrings, string language)
        {
            var loadedStrings = ParseLocalizationFile(localStrings.DisplayName, language);

            foreach (var loadedString in loadedStrings)
            {
                if (LocalizationStringExists(localStrings, loadedString.Key))
                {
                    SetLocalizationString(localStrings, loadedString.Key, loadedString.Value);
                }
            }
        }
Пример #6
0
        private string GetFileContent(ILocalStrings localString)
        {
            var defaultLocalFile = string.Empty;

            foreach (var property in localString.GetType().GetProperties())
            {
                if (property.Name != "DisplayName")
                {
                    defaultLocalFile += string.Format("{0} = {1}\n", property.Name, property.GetValue(localString, null));
                }
            }
            return(defaultLocalFile);
        }
Пример #7
0
 private void CreateDefaultLocalFile(ILocalStrings localString)
 {
     var defaultLocalFile = GetFileContent(localString);
     File.WriteAllText(Path.Combine(_defaultLanguageFolder, "en." + localString.DisplayName + ".sdlang"), defaultLocalFile);
 }
Пример #8
0
 private bool LocalizationExists(ILocalStrings localStrings)
 {
     return
         (_localizationFiles.SingleOrDefault(
              o => Path.GetFileName(o) == string.Format("{0}.{1}.sdlang", _currentLanguage, localStrings.DisplayName)) != null);
 }
Пример #9
0
 private void SetLocalizationString(ILocalStrings localStrings, string propertyName, string value)
 {
     localStrings.GetType().GetProperty(propertyName).SetValue(localStrings, value, null);
 }
Пример #10
0
 private bool LocalizationStringExists(ILocalStrings localStrings, string propertyName)
 {
     return(localStrings.GetType().GetProperty(propertyName) != null);
 }
Пример #11
0
 public LocalStringsItem(string language, ILocalStrings localStrings)
 {
     Language = language;
     LocalStrings = localStrings;
 }
Пример #12
0
 private void SetLocalizationString(ILocalStrings localStrings, string propertyName, string value)
 {
     localStrings.GetType().GetProperty(propertyName).SetValue(localStrings, value, null);
 }
Пример #13
0
 private bool LocalizationStringExists(ILocalStrings localStrings, string propertyName)
 {
     return localStrings.GetType().GetProperty(propertyName) != null;
 }
Пример #14
0
 private bool LocalizationExists(ILocalStrings localStrings)
 {
     return
         _localizationFiles.SingleOrDefault(
             o => Path.GetFileName(o) == string.Format("{0}.{1}.sdlang", _currentLanguage, localStrings.DisplayName)) != null;
 }
Пример #15
0
        private void CreateDefaultLocalFile(ILocalStrings localString)
        {
            var defaultLocalFile = GetFileContent(localString);

            File.WriteAllText(Path.Combine(_defaultLanguageFolder, "en." + localString.DisplayName + ".sdlang"), defaultLocalFile);
        }
Пример #16
0
 public LocalStringsItem(string language, ILocalStrings localStrings)
 {
     Language     = language;
     LocalStrings = localStrings;
 }