Skip to content

Instantly share code, notes, and snippets.

@JohanLarsson
Last active August 29, 2015 13:56
Show Gist options
  • Save JohanLarsson/9177786 to your computer and use it in GitHub Desktop.
Save JohanLarsson/9177786 to your computer and use it in GitHub Desktop.
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);
}
}
}
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