"On" and "Off" values for boolean fields are not translatable

Created on 14 February 2011, over 13 years ago
Updated 31 January 2023, over 1 year ago

We are working on an application with custom content types using fields in core. The site is supposed to be translated to German, and most fields in our content types are translatable, but we have a couple of "checkbox" fields (boolean, "simple on/off checkbox"), which do not seem to translatable, either the label or "help text".

I believe this issue applies to the HEAD version of D7, but we are using v. 7.0 (I can't find any issue which seems to directly relate to what we are seeing with the labels/help text for checkboxes). In fact I just tried to reproduce the issue in HEAD, and found that when I do a default install, turn on the locale module, add German as a site language and turn it on as "default", no German shows up on the site at all. So it seems you need to manually add the translation files in HEAD and I'm not sure what to do there. In the 7.0 version, this seems to be automatic; I think with just the core "Locale" module on and turning on German as the default language (it downloads files, then the site is in German and we can add our own custom translations for our extra fields).

I'll send a link to this issue to my colleague who was actually struggling with this issue today since he can likely add a bit more detail, but apparently this is not an isolated case. In my Google search, I found some discussion related to this issue on a German site:
http://www.drupalcenter.de/node/32639

But as far as I can tell, this issue is new to the queue here.

πŸ› Bug report
Status

Closed: duplicate

Version

8.0 ⚰️

Component
FieldΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡©πŸ‡ͺGermany LoMo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine proweb.ua
      /**
       * {@inheritdoc}
       */
      public function settingsSummary() {
        $summary = [];
        $setting = $this->getSetting('format');
    
        if ($setting == 'custom') {
          $summary[] = $this->t('Custom text: @true_label / @false_label', [
            '@true_label' => $this->getSetting('format_custom_true'),
            '@false_label' => $this->getSetting('format_custom_false'),
          ]);
        }
        else {
          $formats = $this->getOutputFormats();
          $summary[] = $this->t('Display: @true_label / @false_label', [
            '@true_label' => $formats[$setting][0],
            '@false_label' => $formats[$setting][1],
          ]);
        }
    
        return $summary;
      }
    

    change
    '@true_label' => t($this->getSetting('format_custom_true')),
    '@false_label' => t($this->getSetting('format_custom_false')),

      /**
       * {@inheritdoc}
       */
      public function settingsSummary() {
        $summary = [];
        $setting = $this->getSetting('format');
    
        if ($setting == 'custom') {
          $summary[] = $this->t('Custom text: @true_label / @false_label', [
            '@true_label' => t($this->getSetting('format_custom_true')),
            '@false_label' => t($this->getSetting('format_custom_false')),
          ]);
        }
        else {
          $formats = $this->getOutputFormats();
          $summary[] = $this->t('Display: @true_label / @false_label', [
            '@true_label' => $formats[$setting][0],
            '@false_label' => $formats[$setting][1],
          ]);
        }
    
        return $summary;
      }
    
Production build 0.69.0 2024