# cspell:ignore localizable
id: d6_vocabulary_field_instance
label: Vocabulary field instance configuration
migration_tags:
  - Drupal 6
  - Configuration
source:
  plugin: d6_taxonomy_vocabulary_per_type
  constants:
    entity_type: node
    auto_create: true
    selection_handler: 'default:taxonomy_term'
    field_prefix: field_
process:
  entity_type: 'constants/entity_type'
  bundle:
    -
      plugin: migration_lookup
      migration: d6_node_type
      source: type
    -
      plugin: skip_on_empty
      method: row
  # This value is only used in the 'field_name' process pipeline below.
  raw_field_name:
    -
      plugin: migration_lookup
      migration: d6_taxonomy_vocabulary
      source: vid
    -
      plugin: skip_on_empty
      method: row
  field_name:
    # Prepend field_ to avoid conflicts with base fields, and make sure the
    # result is no longer than 32 characters.
    -
      plugin: concat
      source:
        - constants/field_prefix
        - '@raw_field_name'
    -
      plugin: substr
      length: 32
  label: name
  _vid:
    -
      plugin: migration_lookup
      migration:  d6_taxonomy_vocabulary
      source: vid
    -
      plugin: skip_on_empty
      method: row
  'settings/handler': 'constants/selection_handler'
  'settings/handler_settings/target_bundles':
    plugin: target_bundle
  'settings/handler_settings/auto_create': 'constants/auto_create'
  required: required
  # Get the i18n taxonomy translation setting for this vocabulary.
  #  0 - No multilingual options
  #  1 - Localizable terms. Run through the localization system.
  #  2 - Predefined language for a vocabulary and its terms.
  #  3 - Per-language terms, translatable (referencing terms with different
  #  languages) but not localizable.
  translatable:
    plugin: static_map
    source: i18ntaxonomy_vocabulary
    default_value: 0
    map:
      0: false
      1: true
      2: false
      3: true
destination:
  plugin: entity:field_config
migration_dependencies:
  required:
    - d6_node_type
    - d6_vocabulary_field
