private function filterLocales(array $locales)
    {
        $z = self::DEFAULT_SORT_PRIORITY;

        $filteredLocales = [];
        foreach ($locales as $langCode => $locale) {
            if (isset($locale['active']) && !$locale['active']) {
                continue;
            }

            if (!isset($locale['priority'])) {
                $locale['priority'] = $z++;
            }

            if (!isset($locale['locale'])) {
                $locale['locale'] = $langCode;
            }

            $filteredLocales[$langCode] = $locale;
        }

        return $filteredLocales;
    }