Skip to content

Commit

Permalink
WIP: Add i18n languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
melaniekung committed Jun 14, 2024
1 parent f265e91 commit eb4ffa0
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions plugins/arSolrPlugin/lib/arSolrPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,20 @@ protected function initialize()
if ('object' === $value['type']) {
foreach ($value['properties'] as $propertyName => $v) {
array_push($fields, '"'.$subType.':/'.$fieldName.'/'.$propertyName.'"');
//$fName = "${subType}.${fieldName}.${propertyName}";
//array_key_exists($propertyName, $addFieldKeys) ?: $addFieldKeys[$propertyName] = $this->getFieldQuery($fName, $this->setType($v['type']), false);
if ('object' === $v['type']) {
$v['type'] = 'string';
if ($subType === 'i18n') {
$i18nFields = $this->seti18nFields($this->getFieldQuery($propertyName, 'text_general', false));
foreach ($i18nFields as $fieldName => $field) {
$this->log(sprintf('%s: %s', $fieldName, json_encode($field)));
$addFieldKeys[$fieldName] = $field;
}
} else {
//$fName = "${subType}.${fieldName}.${propertyName}";
//array_key_exists($propertyName, $addFieldKeys) ?: $addFieldKeys[$propertyName] = $this->getFieldQuery($fName, $this->setType($v['type']), false);
if ('object' === $v['type']) {
$v['type'] = 'string';
}
array_key_exists($propertyName, $addFieldKeys) ?: $addFieldKeys[$propertyName] = $this->getFieldQuery($propertyName, $this->setType($v['type']), false);
}
array_key_exists($propertyName, $addFieldKeys) ?: $addFieldKeys[$propertyName] = $this->getFieldQuery($propertyName, $this->setType($v['type']), false);
}
} elseif (null != $value['type']) {
array_push($fields, '"'.$subType.':/'.$fieldName.'"');
Expand Down Expand Up @@ -416,6 +424,19 @@ protected function initialize()
}
}

private function seti18nFields($fieldArr) {
$i18nLang = ['en', 'fr', 'es', 'nl', 'pt', 'pt_BR'];
$i18nFields = [];
$fieldName = $fieldArr['name'];
foreach ($i18nLang as $i18n) {
$name = $i18n.'.'.$fieldName;
$fieldArr['name'] = $name;
$i18nFields[$name] = $fieldArr;
$fieldArr['name'] = $fieldName;
}
return $i18nFields;
}

private function addNestedFields($key, $properties)
{
$nestedField = [];
Expand Down

0 comments on commit eb4ffa0

Please sign in to comment.