public void CreateLocalizations(ILocalStrings[] localStrings) { EnsureDefaultLanguageFolder(); foreach (var localString in localStrings) { CreateDefaultLocalFile(localString); } }
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(); }
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); } } }
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; }
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); } } }
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); }
private void CreateDefaultLocalFile(ILocalStrings localString) { var defaultLocalFile = GetFileContent(localString); File.WriteAllText(Path.Combine(_defaultLanguageFolder, "en." + localString.DisplayName + ".sdlang"), defaultLocalFile); }
private bool LocalizationExists(ILocalStrings localStrings) { return (_localizationFiles.SingleOrDefault( o => Path.GetFileName(o) == string.Format("{0}.{1}.sdlang", _currentLanguage, localStrings.DisplayName)) != null); }
private void SetLocalizationString(ILocalStrings localStrings, string propertyName, string value) { localStrings.GetType().GetProperty(propertyName).SetValue(localStrings, value, null); }
private bool LocalizationStringExists(ILocalStrings localStrings, string propertyName) { return(localStrings.GetType().GetProperty(propertyName) != null); }
public LocalStringsItem(string language, ILocalStrings localStrings) { Language = language; LocalStrings = localStrings; }
private bool LocalizationStringExists(ILocalStrings localStrings, string propertyName) { return localStrings.GetType().GetProperty(propertyName) != null; }
private bool LocalizationExists(ILocalStrings localStrings) { return _localizationFiles.SingleOrDefault( o => Path.GetFileName(o) == string.Format("{0}.{1}.sdlang", _currentLanguage, localStrings.DisplayName)) != null; }