PKPLocale::isLocaleValid PHP Method

isLocaleValid() static public method

Check if the supplied locale is currently installable.
static public isLocaleValid ( $locale ) : boolean
$locale string
return boolean
    static function isLocaleValid($locale)
    {
        if (empty($locale)) {
            return false;
        }
        if (!preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $locale)) {
            return false;
        }
        if (file_exists('locale/' . $locale)) {
            return true;
        }
        return false;
    }

Usage Example

Esempio n. 1
0
 function getMainEmailTemplateDataFilename($locale = null)
 {
     if ($locale !== null && !PKPLocale::isLocaleValid($locale)) {
         return null;
     }
     if ($locale === null) {
         $locale = '{$installedLocale}';
     }
     return "locale/{$locale}/emailTemplates.xml";
 }