Last active
August 29, 2015 13:56
-
-
Save JohanLarsson/9177786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public ResxTranslationProvider(ResourceManager resourceManager) | |
| { | |
| _resourceManager = resourceManager; | |
| foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures)) | |
| { | |
| var resourceSet = _resourceManager.GetResourceSet(culture, false, false); | |
| if (resourceSet != null) | |
| { | |
| _languages.Add(culture); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public TranslateExtension(string key) | |
| { | |
| if (key == null) | |
| throw new ArgumentNullException("key"); | |
| if (DesignerProperties.GetIsInDesignMode(DependencyObject)) | |
| { | |
| if (TranslationManager.Instance.TranslationProvider == null) | |
| throw new Exception("TranslationManager.Instance.TranslationProvider==null"); | |
| var translate = TranslationManager.Instance.TranslationProvider.Translate(key); | |
| if (translate == null) | |
| { | |
| throw new Exception(string.Format(@"TranslationManager.Instance.Translate({0})", key)); | |
| } | |
| } | |
| Key = key; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment