Given a locale string, get the list of parameter references of the
form {$myParameterName}.
static public getParameterNames ( $source ) : array | ||
$source | string | |
return | array |
/** * @copydoc GridCellProvider::getTemplateVarsFromRowColumn() */ function getTemplateVarsFromRowColumn($row, $column) { $data = $row->getData(); switch ($column->getId()) { case 'key': return array('key' => $row->getId(), 'strong' => !isset($data[MASTER_LOCALE]) || $data[MASTER_LOCALE] === '' || !isset($data[$this->locale]) || $data[$this->locale] === '' || 0 != count(array_diff(PKPLocale::getParameterNames($data[MASTER_LOCALE]), PKPLocale::getParameterNames($data[$this->locale])))); case 'value': $allLocales = PKPLocale::getAllLocales(); return array('referenceLocale' => MASTER_LOCALE, 'referenceLocaleName' => $allLocales[MASTER_LOCALE], 'reference' => isset($data[MASTER_LOCALE]) ? $data[MASTER_LOCALE] : '', 'translationLocale' => $this->locale, 'translationLocaleName' => $allLocales[$this->locale], 'translation' => isset($data[$this->locale]) ? $data[$this->locale] : ''); } assert(false); }
/** * Get the count of "correctly" translated locale keys for a translation. * @param $referenceLocaleData array Array of locale keys to locale data for reference locale * @param $localeData array Array of locale keys to locale data for the work translation * @return int Number of "correctly" translated locale keys */ protected function _getTranslatedCount($referenceLocaleData, $localeData) { $completeCount = 0; foreach ($referenceLocaleData as $key => $value) { if (!isset($localeData[$key])) { continue; } // Not translated if (0 != count(array_diff(PKPLocale::getParameterNames($value), PKPLocale::getParameterNames($localeData[$key])))) { continue; // Parameters differ } $completeCount++; } return $completeCount; }