PKPNotificationOperationManager::getParamsForCurrentLocale PHP Method

getParamsForCurrentLocale() public method

For each parameter, return (in preferred order) a value for the user's current locale, a param for the journal's default locale, or the first value (in case the value is not localized)
public getParamsForCurrentLocale ( $params ) : array
$params array
return array
    public function getParamsForCurrentLocale($params)
    {
        $locale = AppLocale::getLocale();
        $primaryLocale = AppLocale::getPrimaryLocale();
        $localizedParams = array();
        foreach ($params as $name => $value) {
            if (!is_array($value)) {
                // Non-localized text
                $localizedParams[$name] = $value;
            } elseif (isset($value[$locale])) {
                // Check if the parameter is in the user's current locale
                $localizedParams[$name] = $value[$locale];
            } elseif (isset($value[$primaryLocale])) {
                // Check if the parameter is in the default site locale
                $localizedParams[$name] = $value[$primaryLocale];
            } else {
                // Otherwise, iterate over all supported locales and return the first match
                $locales = AppLocale::getSupportedLocales();
                foreach ($locales as $localeKey) {
                    if (isset($value[$localeKey])) {
                        $localizedParams[$name] = $value[$localeKey];
                    }
                }
            }
        }
        return $localizedParams;
    }