puppetlabs/puppet · error · Puppet::Error
Unsupported translation file format #
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.
Solutions
- Use :po — puppet loads .po files directly at runtime — or :mo if you ship compiled catalogs.
- Pass a Symbol, not a String; 'po' fails the casecmp-style equality against :po.
- 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
- Pass Symbols, not Strings, for the format argument.
- Default to :po — it is puppet's runtime translation format.
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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- A project name must be specified in order to initialize…
- Auth names must be provided, not numbers
- Class name must be provided.
- Could not determine module path
- Each entry for purge_ssh_keys must be a string, not a
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/9d32d059feda5f27.
Report an issue: GitHub.
Appendix: 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)