{"record":{"id":"572e75fef71126a3","repo":"puppetlabs/puppet","slug":"a-project-name-must-be-specified-in-order-to-initi","errorCode":null,"errorMessage":"A project name must be specified in order to initialize translations.","messagePattern":"A project name must be specified in order to initialize translations\\.","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/gettext/config.rb","lineNumber":230,"sourceCode":"      :po\n    end\n  end\n\n  # @api private\n  # Prevent future gettext initializations\n  def self.disable_gettext\n    @gettext_disabled = true\n  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","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/gettext/config.rb#L212-L248","documentation":"Puppet::GettextConfig.load_translations binds a FastGettext repository for a named project (project_name) under a locale directory. It refuses nil or empty project names because gettext cannot register an anonymous repository, raising Puppet::Error before any filesystem or format work happens.","triggerScenarios":"Calling Puppet::GettextConfig.load_translations(nil, dir, :po) or load_translations('', dir, :mo) — typically from custom entrypoints that embed puppet (gems, packaging scripts, puppetserver-side wrappers) and skip puppet's normal initialization, or from specs that stub the gettext config with nil.","commonSituations":"Downstream distributions wiring their own translation setup; test helpers passing a variable that was never assigned; refactors where the project name constant was dropped; JRuby hosts initializing puppet partially.","solutions":["Pass the real project name under which the .po files are compiled (e.g. 'puppet' or 'puppet-agent').","Prefer puppet's own initialization (Puppet::GettextConfig.load_default_text_domain or full Puppet initialization) instead of calling load_translations directly.","Check the caller's stack to find which code path supplies the nil name if it is not obvious."],"exampleFix":"# before\nPuppet::GettextConfig.load_translations(nil, locale_dir, :po)\n\n# after\nPuppet::GettextConfig.load_translations('puppet', locale_dir, :po)","handlingStrategy":"validation","validationCode":"project = project_name.to_s\nraise ArgumentError, 'project_name required' if project.empty?\nPuppet::GettextConfig.load_translations(project, locale_dir, :po)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not call translation internals directly; use puppet's normal initialization.","Fail fast on nil config values at your own entrypoint instead of forwarding them."],"tags":["puppet","gettext","i18n","fast-gettext","initialization"],"backgroundTag":"missing-required-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}