{"record":{"id":"9d32d059feda5f27","repo":"puppetlabs/puppet","slug":"unsupported-translation-file-format-file-format","errorCode":null,"errorMessage":"Unsupported translation file format #{file_format}; please use :po or :mo","messagePattern":"Unsupported translation file format #(.+?); please use :po or :mo","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/gettext/config.rb","lineNumber":238,"sourceCode":"  end\n\n  # @api private\n  # Attempt to load translations for the given project.\n  # @param [String] project_name the project whose translations we want to load\n  # @param [String] locale_dir the path to the directory containing translations\n  # @param [Symbol] file_format translation file format to use, either :po or :mo\n  # @return true if initialization succeeded, false otherwise\n  def self.load_translations(project_name, locale_dir, file_format, text_domain = FastGettext.text_domain)\n    if project_name.nil? || project_name.empty?\n      raise Puppet::Error, \"A project name must be specified in order to initialize translations.\"\n    end\n\n    return false if @gettext_disabled || !@gettext_loaded\n\n    return false unless locale_dir && Puppet::FileSystem.exist?(locale_dir)\n\n    unless file_format == :po || file_format == :mo\n      raise Puppet::Error, \"Unsupported translation file format #{file_format}; please use :po or :mo\"\n    end\n\n    add_repository_to_domain(project_name, locale_dir, file_format, text_domain)\n    true\n  end\n\n  # @api private\n  # Add the translations for this project to the domain's repository chain\n  # chain for the currently selected text domain, if needed.\n  # @param [String] project_name the name of the project for which to load translations\n  # @param [String] locale_dir the path to the directory containing translations\n  # @param [Symbol] file_format the format of the translations files, :po or :mo\n  def self.add_repository_to_domain(project_name, locale_dir, file_format, text_domain = FastGettext.text_domain)\n    return if @gettext_disabled || !gettext_loaded?\n\n    current_chain = FastGettext.translation_repositories[text_domain].chain\n\n    repository = FastGettext::TranslationRepository.build(project_name,","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/gettext/config.rb#L220-L256","documentation":"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.","triggerScenarios":"Calling load_translations('proj', dir, :json) or another unsupported symbol; passing a String like 'po' or ':po' instead of the Symbol :po.","commonSituations":"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.","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."],"exampleFix":"# before\nPuppet::GettextConfig.load_translations('puppet', locale_dir, 'po')\n\n# after\nPuppet::GettextConfig.load_translations('puppet', locale_dir, :po)","handlingStrategy":"type-guard","validationCode":"raise ArgumentError, \"format must be :po or :mo\" unless %i[po mo].include?(file_format)\nPuppet::GettextConfig.load_translations(project, dir, file_format)","typeGuard":"VALID_FORMATS = %i[po mo].freeze\nvalid = ->(f) { VALID_FORMATS.include?(f) }\nraise ArgumentError unless valid.call(file_format)","tryCatchPattern":null,"preventionTips":["Pass Symbols, not Strings, for the format argument.","Default to :po — it is puppet's runtime translation format."],"tags":["puppet","gettext","i18n","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}