Skip to content

Instantly share code, notes, and snippets.

@DASPRiD
Created July 3, 2012 20:59
Show Gist options
  • Save DASPRiD/3043035 to your computer and use it in GitHub Desktop.
Save DASPRiD/3043035 to your computer and use it in GitHub Desktop.
<?php
/**
* Check if a message is translated.
*
* @param string $message
* @param string $textDomain
* @param string $locale
* @return boolean
*/
public function isTranslated($message, $textDomain = 'default', $locale = null)
{
$locale = ($locale ?: $this->getLocale());
$translation = $this->getTranslatedMessage($message, $locale, $textDomain);
if ($translation !== null && $translation !== '') {
return true;
}
if (null !== ($fallbackLocale = $this->getFallbackLocale())
&& $locale !== $fallbackLocale
) {
return $this->isTranslated($message, $textDomain, $fallbackLocale);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment