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; }