private function setLocales(array $locales)
    {
        $locales = $this->filterLocales($locales);
        uasort($locales, [ $this, 'sortLocalesByPriority' ]);

        $this->locales   = [];
        $this->languages = [];
        foreach ($locales as $langCode => $locale) {
            $this->locales[$langCode] = $locale;
            $this->languages[] = $langCode;
        }

        if (empty($this->locales)) {
            throw new InvalidArgumentException(
                'Locales can not be empty.'
            );
        }
    }