LocalizationManager API request

More
10 years 3 weeks ago #340 by Jos
We have found that the default return type of string.empty for the LocalizationManager.GetTermTranslation() method is sometimes not what we want.

I've implemented the following method, and would like to request that it, or something like it, be added to the public API.
public static bool TryGetTermTranslation(string Term, out string Translation)
{
	Translation = string.Empty;

	for (int i=0, imax=Sources.Count; i<imax; ++i)
	{
		string val = Sources[i].GetTermTranslation (Term);
		if (!string.IsNullOrEmpty(val))
		{
			Translation = val;
			return true;
		}
	}
	return false;
}

This also removes a HasTermTranslation() method that we had added before as well.

Thanks!

Jos

Please Log in or Create an account to join the conversation.

More
10 years 3 weeks ago #345 by Frank
Hi,
Ok, I added that method to the LocalizationManager. So you could do GetTermTranslation() or TryGetTermTranslation().

I changed the method a bit and instead of Sources.GetTermTranslation I added a Sources.TryGetTranslation. That way you could differentiate between string.Empty and not existent terms.

I will release that change in the 2.3.1 b2 tomorrow or latter today.

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The following user(s) said Thank You: Jos

Please Log in or Create an account to join the conversation.

More
10 years 3 weeks ago #349 by Jos
Replied by Jos on topic LocalizationManager API request
That is great, thanks!

Jos

Please Log in or Create an account to join the conversation.

Time to create page: 0.157 seconds
Template by JoomlaShine