protected function getLocale($acceptLanguageHeader)
    {
        $acceptLanguageHeader = str_replace('-', '_', $acceptLanguageHeader);
        $locales = explode(',', $acceptLanguageHeader);
        
        $acceptableLocales = array();
        foreach ($locales as $locale) {
            $priority = 1;
            if (strpos($locale, ';') !== false) {
                $priority = floatval(substr($locale, strpos($locale, ';')));
                $locale = substr($locale, 0, strpos($locale, ';'));
            }
            
            $acceptableLocales[$priority] = $locale;
        }
        
        krsort($acceptableLocales);
        
        // Get the first locale - it will have the highest priority
        $locale = array_shift($acceptableLocales);
        
        if ($locale == '') {
            $locale = 'en_US';
        } else if (strpos($locale, '_') === false) {
            $locale = $locale . '_' . strtoupper($locale);
        }
        
        return $locale;
    }