In fields dialog the "File" (and probably some other) strings are passed to t() two times. This mostly does nothing but a little overhead, but in Estonian this may lead to strange results, since "File" → "Fail" and "Fail" → "Ebaõnnestunud", which is far from the original meaning.
I think that having t('File') is good for translation collection scripts, but the second one may be needed (or may not) to translate user fields. So the t() markers should be removed from the field_ui_admin.inc

/modules/file/file.field.inc@12-15

function file_field_info() {
  return array(
    'file' => array(
      'label' => t('File'),

modules/field_ui/field_ui_admin.inc@351-361

      'type' => array(
        '#type' => 'link',
        '#title' => $field_types[$field['type']]['label'],
        '#href' => $admin_field_path . '/field-settings',
        '#options' => array('attributes' => array('title' => t('Edit field settings.'))),
      ),
      'widget_type' => array(
        '#type' => 'link',
        '#title' => $widget_types[$instance['widget']['type']]['label'],
        '#href' => $admin_field_path . '/widget-type',
        '#options' => array('attributes' => array('title' => t('Change widget type.'))),
CommentFileSizeAuthor
#2 915592-field_ui_double_translation.patch1015 bytesfranz

Comments

mahfiaz’s picture

For testing add to /includes/bootstrap.inc@1442,1463 to return call some additional marker, like:
return $string."↑";

This way you will see, that a awful amount of strings suffer the same plague of overtranslating. This usually does not ruin anything but performance, but sometimes it does (as the above example). Also such behaviour can add unnecessarily already translated strings to translation database.

franz’s picture

Version: 7.0-alpha7 » 8.x-dev
Component: file.module » field_ui.module
Status: Active » Needs review
Issue tags: +Needs backport to D7
StatusFileSize
new1015 bytes

If I get the issue well, this is a problem with field_ui module then. Are you sure this modification won't affect other fields?

mahfiaz’s picture

Status: Needs review » Reviewed & tested by the community

Sorry for taking so long to come back to this. I tested this again and all the other widgets still had translated names after applying this. Committing this is safe.

(you may skip this:)
If a module (none that I am not aware of) ought to let user define their own customized field types and widgets from UI (not by writing a new module), then it is the problem of that module, also doing so does not make much sense, at least not in the next decade (Drupal is too configurable as it is, there is no need to create a framework for a framework :) ).

webchick’s picture

Assigned: Unassigned » gábor hojtsy
Status: Reviewed & tested by the community » Needs review

Hmmm. Not sure about this. This seems like it could cause existing sites to suddenly be seeing English strings, at least in D7. Assigning to Gábor to get his thoughts.

mahfiaz’s picture

I tested this with Drupal 7.
Modules translate widget names and types in the place where the name and type string originates from. If they didn't, the strings would not end up in the .po file and localize and would be only available for translation after the string is first time passed through t().
As I mentioned earlier, the only way for such untranslated strings is if users could define their own field types directly from UI. This is totally unnecessary, as we use modules which define field and widget types (and setting database column types and defining widget code will hopefully never reach Drupal UI). AFAIK there is no such module.

gábor hojtsy’s picture

Is this label not already configurable? I don't really know this area of the code well to be honest.

damien tournoud’s picture

Status: Needs review » Needs work

_field_info_collate_fields() doesn't collate by language, so the t() in file_field_info() needs to go away.

droplet’s picture

Is there any document about it for developers

mahfiaz’s picture

Status: Needs work » Needs review

These two strings appear as third (Field) and fourth (Widget) column in /admin/structure/types/manage/article/fields
I have never seen a place to configure these names, although I have wandered around in admin interface quite a lot.

Damien, if you remove t() functions from the _field_info_collate_fields(), these strings do not reach .po file, unless we create a dummy function with all the entries, like:

function module_dummy_translation() {
$foo = t('Image');
$foo = t('File');
$foo = t('Taxonomy reference');
}

I would like to be proven wrong here, that would be a nasty workaround.

gábor hojtsy’s picture

Can someone post a "call-graph", ie. tracking down where things are called, so we have a better idea of how this data is used?

damien tournoud’s picture

Status: Needs review » Needs work

This is needs work based on #7: either we need to collate and cache by language in _field_info_collate_fields(), or we need to remove the t() from the various info hooks.

mahfiaz’s picture

Status: Needs work » Needs review

Damien, sorry for the status change, it was accidental.

Gábor, unfortunately I can use xhprof only in localhost and cannot provide you with a link. But the chain is as follows:
_field_info_collate_fields → field_info_field → field_ui_fields_list → call_user_func_array → (and I suppose) menu_execute_active_handler

mahfiaz’s picture

Status: Needs review » Needs work

Argh, Firefox tries to outsmart me.
Maybe I should also note that this chain was for /admin/reports/fields

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jhedstrom’s picture

Issue summary: View changes
Status: Needs work » Postponed (maintainer needs more info)

The methods in the IS have been completely overhauled, so I don't think this is still an issue in 8.x?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

There has been no activity here for 4 years 7 months.

As said in #16, the methods have been changed. I did try to reproduce the problem with a standard install of 9.2.x and was not able to do so.

Therefore, closing as cannot reproduce. If you are experiencing this problem reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!