Cybermano Posted 15 hours ago Posted 15 hours ago (edited) Hi everybody, I'm trying to translate options into already activated languages, via hook: setOptionString works correctly for the default language, but I can't populate the options in other languages. More specifically, changing the user profile language the titles are translated, but the options are overwritten in the "default" language tab. So I have found the setOptionsStringLanguages method, but it seems to break someting (I have an error like: ProcessPageEdit:Multi language not enabled.. of course it's enabled) The scenario is a hook for an inputfield:render Spoiler $wire->addHookBefore('InputfieldSelect::render', 'optionPopulate'); function optionPopulate($event){ $inputfield = $event->object; if ($inputfield->name != "MY_FIELD_NAME") return; $pages = wire('pages')->find('template=MY_TEMPLATE, sort=sort, registration=1'); // Set the groups in the field $field1 = wire('fields')->get('MY_FIELD_NAME'); $field1->useLanguages = true; // It seems to do nothing (?) $manager1 = new SelectableOptionManager(); $langOptions = []; foreach (wire('languages') as $lang) { $options = ''; $langOptions[$lang->id] = ''; foreach ($pages as $p){ $options .= $p->id . '=' . ($p->getLanguageValue($lang->id,'title') ?? $p->title.$lang->id).' '; } $options .= '99=' . __('Independent', '/site/templates/transaltions/front_end.php').' '; $langOptions[$lang->id] = $options; // SECOND APPROACH: FORCING OPTION BY EACH LANGUAGES, BUT DO NOTHING // wire('user')->laguage = $lang; // $manager1->setOptionsString($field1, $langOptions[$lang->id], true); } // FIRST APPROACH: PageEdit Error: MultiLanguage Support not activated (???) $manager1->setOptionsStringLanguages($field1, $langOptions, true); } Any suggestion? Thanks in advance. Edited 15 hours ago by Cybermano Typos
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now