Mercurial > repos > IBBoard
diff Lang/Translation.cs @ 69:b5d7e8b93205
Re #30: Improve Translations API
* Add translation sets
* Add reset method to translations
* Fix translations where API documentation (contract) didn't match behaviour
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 06 Apr 2010 15:41:20 +0000 |
parents | 5fb2e5a2e7a8 |
children | 40c09e57d213 |
line wrap: on
line diff
--- a/Lang/Translation.cs Sat Mar 06 19:59:37 2010 +0000 +++ b/Lang/Translation.cs Tue Apr 06 15:41:20 2010 +0000 @@ -62,7 +62,7 @@ } else { - throw new TranslationLoadException("Translation path not found ("+translationPath+")"); + throw new TranslationLoadException("Translation path not found ("+new FileInfo(translationPath).FullName+")"); } } @@ -180,6 +180,15 @@ { throw new TranslationLoadException("Problem validating schema for translation: " + e.Exception.Message, e.Exception); } + + /// <summary> + /// Resets the loaded translations + /// </summary> + public static void Reset() + { + translationsLocal.Clear(); + translationsDefault.Clear(); + } /// <summary> /// Loads translations for a given language and sets them as the local language. @@ -300,7 +309,7 @@ private static string GetDefaultTranslation(string translationID, string defaultTranslation) { - return (defaultTranslation != "" && defaultTranslation != null) ? defaultTranslation : GetMissingTranslationMessage(translationID); + return (defaultTranslation != "" || defaultTranslation == null) ? defaultTranslation : GetMissingTranslationMessage(translationID); } private static string GetMissingTranslationMessage(string translationID) @@ -330,7 +339,7 @@ /// </param> public static void Translate(ITranslatable item, params object[] replacements) { - Translate(item, (string)null, replacements); + Translate(item, GetMissingTranslationMessage(item.Name), replacements); } /// <summary>