Welcome, Guest
Username: Password: Remember me

TOPIC: Translation key existence

Translation key existence 2 weeks 6 days ago #3562

  • elusiven
  • elusiven's Avatar
  • Offline
  • New Member
  • Posts: 14
  • Karma: 0
Hi is there a way to check before getting translation via script localization that it exists so that I can perform my own kind of fallback?
The administrator has disabled public write access.

Translation key existence 2 weeks 6 days ago #3565

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1202
  • Thank you received: 256
  • Karma: 78
Hi,
You can use:
TermData term = LocalizationManager.GetTermData( termName );
if (term==null)
{
  // There is no term named termName
}

If you also want to check if the term exist but is not translated to the current language:
string translation;
bool termExists = LocalizationManager.TryGetTranslation(termName, out translation );
if (!termExists || translation==null)
{
  // There is no term named termName or there is no translation to the current language
}

Hope that helps,
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 administrator has disabled public write access.
Time to create page: 0.118 seconds
Template by JoomlaShine