private void VerifyIntegrity() { if (this.BaseTranslation == null) { throw new InvalidDataException("Could not find file for BaseLocale: " + Translation <Locale, Key> .GetFile(this.Folder, this.BaseLocale)); } if (this.DefaultTranslation == null) { throw new InvalidDataException("Could not find file for DefaultLocale: " + Translation <Locale, Key> .GetFile(this.Folder, this.DefaultLocale)); } for (int index = 0; index < this.Translations.Length; ++index) { Translation <Locale, Key> translation = this.Translations[index]; if (translation == null || translation.Locale.ToInt32((IFormatProvider)null) != index) { this.Translations[index] = this.DefaultTranslation; } } }
private void VerifyIntegrity() { if (BaseTranslation == null) { throw new InvalidDataException("Could not find file for BaseLocale: " + Translation <Locale, Key> .GetFile(Folder, BaseLocale)); } if (DefaultTranslation == null) { throw new InvalidDataException("Could not find file for DefaultLocale: " + Translation <Locale, Key> .GetFile(Folder, DefaultLocale)); } for (int index = 0; index < Translations.Length; ++index) { Translation <Locale, Key> translation = Translations[index]; if (translation == null || translation.Locale.ToInt32(null) != index) { Translations[index] = DefaultTranslation; } } }
public static Translation <L, K> Load(ILocalizer <L> localizer, L locale) { string file = Translation <L, K> .GetFile(localizer.Folder, locale); if (!File.Exists(file)) { return((Translation <L, K>)null); } try { Translation <L, K> translation = XmlFile <Translation <L, K> > .Load(file); translation.Localizer = localizer; translation.Locale = locale; translation.SortItems(); return(translation); } catch (Exception ex) { throw new IOException("Unable to load Localization file " + file, ex); } }