How do I access the settings defined in the config section within a custom ITranslationProvider?
I'm working on a custom integration for a translation service a client uses, but I'm unsure how to access the settings set during configuration inside the custom TranslationProvider. I did notice a ProviderProperties field on the TranslationJob object, which I assume includes this information, but this object isn't available in the Active method. I want to flag it as active if it has an api key set in its settings. Is this possible?
While I can get around this by adding the api key in app settings, I would like to manage all of the configuration in a single place that an umbraco user can easily access.
there is also a generic version GetProviderSetting<TValue>(string providerName, string key, TValue defaultValue)
which will let you get the value by type, e.g.
int throttle = TranslateConfigHelper.GetProviderSetting(this.Alias, "throttle", 100);
Also worth noting that if you store these values within the class, then you should load them in the Reload method, this is called by translation Manager when a user saves settings via the UI,
How do I access the settings defined in the config section within a custom ITranslationProvider?
I'm working on a custom integration for a translation service a client uses, but I'm unsure how to access the settings set during configuration inside the custom TranslationProvider. I did notice a ProviderProperties field on the TranslationJob object, which I assume includes this information, but this object isn't available in the Active method. I want to flag it as active if it has an api key set in its settings. Is this possible?
While I can get around this by adding the api key in app settings, I would like to manage all of the configuration in a single place that an umbraco user can easily access.
Hi Jesse,
There are helper methods that allow you to get to the provider settings in the translations.config file.
so within the provider, this would get the value for 'apiKey'
there is also a generic version
GetProviderSetting<TValue>(string providerName, string key, TValue defaultValue)
which will let you get the value by type, e.g.Also worth noting that if you store these values within the class, then you should load them in the
Reload
method, this is called by translation Manager when a user saves settings via the UI,Thanks for the quick response Kevin.
is working on a reply...