0

Theme settings are not translatable in core. Is there a way to make them translatable? I have some additional theme settings which needs to have different values per language.

I'm trying to achieve something like this - How do I translate theme settings?

What I have so far -

mytheme/config/schema/mytheme.schema.yml

mytheme.settings:
  type: theme_settings
  label: 'My theme settings'
  mapping:
    custom_textarea:
      type: text_format
      label: 'Additional settings'

mytheme/config/install/mytheme.settings.yml

custom_textarea:
  value: "<p><sup>*</sup>this is an additional settings.</p>\r\n"
  format: full_html
langcode: en

mytheme/mytheme.config_translation.yml

mytheme.settings:
  title: 'my theme settings'
  base_route_name: system.theme_settings
  names:
    - mytheme.settings

theme-settings.php

/**
 * Implements hook_form_system_theme_settings_alter().
 *
 * Form override for theme settings.
 */
function mytheme_form_system_theme_settings_alter(array &$form, FormStateInterface $form_state) {


  $custom_textarea = theme_get_setting('custom_textarea');
  $form['custom_textarea'] = [
    '#type'          => 'text_format',
    '#title'         => t('custom textarea'),
    '#format'        => 'full_html',
    '#default_value' => $custom_textarea['value'],
  ];


}

When I navigate to admin/config/regional/config-translation it shows the 'my theme settings' but when I click on Translate it navigates to admin/appearance/settings/translate and returns Access Denied.

I also tried updating the base_route_name in mytheme.config_translation.yml to system.theme_settings_theme but when I navigage to admin/appearance/settings/mytheme/translate it throws a fatal error.

Looking forward for any suggestions.

  • Do you use different domains per language? Are you being redirected to a different domain where you haven't logged in yet? – leymannx Jul 19 at 17:32
  • All the languages are in a single domain. It's not multi site or multi domain. – wilNev Jul 20 at 12:05
0

in schema change field type to text and add translatable: true

mytheme.settings:
  type: theme_settings
  label: 'My theme settings'
  mapping:
    custom_textarea:
      type: text
      label: 'Additional settings'
      translatable: true

You may also face this problem later https://www.drupal.org/project/drupal/issues/2719553 (my reply there is the last from current date)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.