# Schema for the configuration files of the Language module.

language_type_negotiation:
  type: mapping
  label: 'Language negotiation per type setting'
  mapping:
    enabled:
      type: sequence
      label: 'Enabled negotiators'
      sequence:
        type: integer
        label: Weight
    method_weights:
      type: sequence
      label: 'Negotiator weights'
      sequence:
        type: integer
        label: Weight

language.types:
  type: config_object
  label: 'Language types'
  mapping:
    all:
      type: sequence
      label: 'All language types'
      sequence:
        type: string
        label: 'Language type'
    configurable:
      type: sequence
      label: 'Configurable language types'
      sequence:
        type: string
        label: 'Language type'
    negotiation:
      type: sequence
      label: 'Language negotiation per type settings'
      sequence:
        type: language_type_negotiation
        label: 'Language negotiation per type setting'

language.negotiation:
  type: config_object
  label: 'Language detection methods'
  mapping:
    session:
      type: mapping
      label: 'Session'
      mapping:
        parameter:
          type: string
          label: 'Request/session parameter'
    url:
      type: mapping
      label: 'Language from the URL (Path prefix or domain).'
      mapping:
        source:
          type: string
          label: 'Part of the URL that determines language'
        prefixes:
          type: sequence
          label: 'Path prefix configuration'
          sequence:
            type: string
            label: 'Path prefix'
        domains:
          type: sequence
          label: 'Domain configuration'
          sequence:
            type: string
            label: 'Domain'
    selected_langcode:
      type: langcode
      label: 'Selected language'

language.mappings:
  type: config_object
  label: 'Language mapping'
  mapping:
    map:
      type: sequence
      sequence:
        type: string
        label: 'Language'

language.entity.*:
  type: config_entity
  label: 'Language'
  constraints:
    FullyValidatable: ~
  mapping:
    id:
      type: string
      label: 'ID'
      constraints:
        NotBlank: []
        Regex:
          # @see \Drupal\Core\Language\LanguageInterface::VALID_LANGCODE_REGEX
          pattern: '/[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*/'
          message: 'This is not a valid language code.'
    label:
      type: required_label
      label: 'Label'
    direction:
      type: string
      label: 'Direction'
      constraints:
        # @see \Drupal\Core\Language\LanguageInterface::DIRECTION_LTR and
        # \Drupal\Core\Language\LanguageInterface::DIRECTION_RTL
        Choice: [ 'ltr', 'rtl' ]
    weight:
      type: weight
      label: 'Weight'
    locked:
      type: boolean
      label: 'Locked'

language.content_settings.*.*:
  type: config_entity
  label: 'Content Language Settings'
  constraints:
    FullyValidatable: ~
  mapping:
    id:
      type: string
      label: 'ID'
      constraints:
        NotBlank: []
    target_entity_type_id:
      type: string
      label: 'Entity Type ID'
      constraints:
        PluginExists:
          manager: entity_type.manager
          interface: Drupal\Core\Entity\ContentEntityInterface
    target_bundle:
      type:  string
      label: 'Bundle'
      constraints:
        EntityBundleExists: '%parent.target_entity_type_id'
    default_langcode:
      type: langcode
      label: 'Default language'
      constraints:
        Choice:
          # The "default language" has a different list of allowed values.
          callback: '\Drupal\language\Entity\ContentLanguageSettings::getAllValidDefaultLangcodes'
    language_alterable:
      type: boolean
      label: 'Allow to alter the language'

condition.plugin.language:
  type: condition.plugin
  mapping:
    langcodes:
      type: sequence
      sequence:
        type: langcode
