Skip to content
Snippets Groups Projects
Commit e8576ec1 authored by Shibin Das's avatar Shibin Das
Browse files

Issue #3496002: Update Translation Edit Form labels to use human friendly Labels

parent 5ade46f9
Branches
Tags
No related merge requests found
<?php
/**
* @file
* String Plural Form Module file.
*/
use Drupal\Core\Render\Element;
/**
* Implements hook_form_FORM_ID_alter().
*/
function string_plural_form_form_locale_translate_edit_form_alter(&$form, $form_state) {
if (isset($form['strings'])) {
$config = \Drupal::config('string_plural_form.settings')
->get('rules');
$lang_code = $form["langcode"]["#value"];
if (empty($config[$lang_code])) {
return;
}
$instance = \Drupal::service('plugin.manager.string_plural_form')->createInstance($config[$lang_code]);
foreach (Element::children($form['strings']) as $key) {
$item = &$form['strings'][$key];
if (isset($item['translations'][1])) {
foreach (Element::children($item['translations']) as $index) {
$form['strings'][$key]['translations'][$index]['#title'] = $instance->getIndexLabel($index);
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment