puppetlabs/puppet · error · Puppet::Error

Unsupported translation file format #{file_format}; please u

Error message

Unsupported translation file format #{file_format}; please use :po or :mo

What it means

Puppet::GettextConfig.load_translations only accepts :po or :mo as the translation file format; anything else raises Puppet::Error. The check runs after the project-name, disabled, and locale-dir checks, so a bad format only surfaces once the rest is valid.

Source

Thrown at lib/puppet/gettext/config.rb:238

  end

  # @api private
  # Attempt to load translations for the given project.
  # @param [String] project_name the project whose translations we want to load
  # @param [String] locale_dir the path to the directory containing translations
  # @param [Symbol] file_format translation file format to use, either :po or :mo
  # @return true if initialization succeeded, false otherwise
  def self.load_translations(project_name, locale_dir, file_format, text_domain = FastGettext.text_domain)
    if project_name.nil? || project_name.empty?
      raise Puppet::Error, "A project name must be specified in order to initialize translations."
    end

    return false if @gettext_disabled || !@gettext_loaded

    return false unless locale_dir && Puppet::FileSystem.exist?(locale_dir)

    unless file_format == :po || file_format == :mo
      raise Puppet::Error, "Unsupported translation file format #{file_format}; please use :po or :mo"
    end

    add_repository_to_domain(project_name, locale_dir, file_format, text_domain)
    true
  end

  # @api private
  # Add the translations for this project to the domain's repository chain
  # chain for the currently selected text domain, if needed.
  # @param [String] project_name the name of the project for which to load translations
  # @param [String] locale_dir the path to the directory containing translations
  # @param [Symbol] file_format the format of the translations files, :po or :mo
  def self.add_repository_to_domain(project_name, locale_dir, file_format, text_domain = FastGettext.text_domain)
    return if @gettext_disabled || !gettext_loaded?

    current_chain = FastGettext.translation_repositories[text_domain].chain

    repository = FastGettext::TranslationRepository.build(project_name,

View on GitHub (pinned to e227c27540)

Solutions

  1. Use :po — puppet loads .po files directly at runtime — or :mo if you ship compiled catalogs.
  2. Pass a Symbol, not a String; 'po' fails the casecmp-style equality against :po.
  3. Check the method signature before calling in custom packaging scripts.

Example fix

# before
Puppet::GettextConfig.load_translations('puppet', locale_dir, 'po')

# after
Puppet::GettextConfig.load_translations('puppet', locale_dir, :po)
Defensive patterns

Strategy: type-guard

Validate before calling

raise ArgumentError, "format must be :po or :mo" unless %i[po mo].include?(file_format)
Puppet::GettextConfig.load_translations(project, dir, file_format)

Type guard

VALID_FORMATS = %i[po mo].freeze
valid = ->(f) { VALID_FORMATS.include?(f) }
raise ArgumentError unless valid.call(file_format)

Prevention

When it happens

Trigger: Calling load_translations('proj', dir, :json) or another unsupported symbol; passing a String like 'po' or ':po' instead of the Symbol :po.

Common situations: Porting older fast_gettext add_repository code that took format-agnostic options; custom locale tooling that assumes a different enumeration; test doubles hard-coding a wrong format.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/9d32d059feda5f27. Report an issue: GitHub.