Hey there,

I was wondering why is it only possible to specify the language of an FPP if the entity_translation module is being used? Many sites use content translation and other solutions but still need the possibility to specify a language on the FPP. Attached patch makes is possible to do so if the site is not using entity translation (in which case it's not necessary).

The patch also contains some more views integration so that you can display the FPP language and filter by it.

Cheers!

Comments

damienmckenna’s picture

Status: Needs review » Needs work

Could you please review other entities (e.g node) to confirm what they look for in order to display the language selector? Thanks.

upchuk’s picture

StatusFileSize
new1.22 KB
new4.79 KB

So basically the node module does nothing, but the Locale module does it for the node.

When locale is enabled, you can have multiple languages. If you edit a node type and enable multilingual on it, the form_alter kicks in on the nodes of that type and the language selector gets printed:

function locale_form_node_form_alter(&$form, &$form_state) {
  if (isset($form['#node']->type) && locale_multilingual_node_type($form['#node']->type)) {
    $form['language'] = array(
      '#type' => 'select',
      '#title' => t('Language'),
      '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''),
      '#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'),
    );
  }
  // Node type without language selector: assign the default for new nodes
  elseif (!isset($form['#node']->nid)) {
    $default = language_default();
    $form['language'] = array(
      '#type' => 'value',
      '#value' => $default->language
    );
  }
  $form['#submit'][] = 'locale_field_node_form_submit';
}

I suppose we could replicate this by enabling multilingual on individual FPP bundles but this is up to you guys. It's not difficult either, we just need to add the same multilingual selector on the bundle edit form (admin/structure/fieldable-panels-panes/fieldable_panels_pane/edit) and save it to a variable (exactly like locale does for node types). Then we apply based on that either directly a language value or a selector. Let me know if you wanna do this. (Also keep in mind what locale_field_node_form_submit() does)

Based on my finding, I cleaned up a bit the language selector:

  • Used the same technique as locale
  • Realized we don't need a check for entity translation because if it's enabled it will just replace the language selector. I guess this is what happens to node as well.
damienmckenna’s picture

Status: Needs work » Needs review
damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Apologies for the delay in getting to this.

This issue needs a tests to confirm that at least the edit form works as intended. Also, the methods need docblock comments.

damienmckenna’s picture

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new9.56 KB

This adds some tests.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks!

  • DamienMcKenna committed 5948c4b on 7.x-1.x authored by Upchuk
    Issue #2493899 by Upchuk, DamienMcKenna: Language selector on FPP entity...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

AgentJay’s picture

This doesn't seem to work correctly. When I create an FPP entity and select a language I can't go back and edit that entity. It seems to be saving the entity with the default 'language neutral' language option.

AgentJay’s picture

It works fine for newly created FPP entities. It's only ones that were already created before this update that have an issue.

betz’s picture

Status: Closed (fixed) » Needs work

I can conform this bug.
I had to upgrade an old panopoly distro, and all my existing panel pages with FPP on it have empty fields.
Doing the upgrade again, but locking the upgrade with FPP v1.8 worked fine.

damienmckenna’s picture

Status: Needs work » Fixed

Please open a new issue for follow-on problems. Thank you.

betz’s picture

❤️

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.