Bot::Cobalt::Lang - Bot::Cobalt language set loader


  use Bot::Cobalt::Lang;

  ## Load 'english.yml' from language dir:
  my $english = Bot::Cobalt::Lang->new(
    lang     => 'english',    
    lang_dir => $path_to_lang_dir,
  ## Access loaded RPL hash:
  my $str = $english->rpls->{$rpl};

  ## Fall back to core set:
  my $language = Bot::Cobalt::Lang->new(
    use_core => 1,
    lang     => $language,
    lang_dir => $lang_dir,
  ## Use an absolute path:
  my $language = Bot::Cobalt::Lang->new(
    lang => "mylangset",
    absolute_path => $path_to_my_lang_yaml,

  ## Load only the core (built-in) set:
  my $coreset = Bot::Cobalt::Lang->new(
    lang => 'coreset',
    use_core_only => 1,


Bot::Cobalt::Lang provides language set loading facilities to Bot::Cobalt and extensions.

This is primarily used by Bot::Cobalt::Core to feed the core lang() hash.

new() requires a 'lang' option and either a 'lang_dir' or 'absolute_path' -- if an absolute path is not specified, the named 'lang' is (attempted to be) loaded from the specified 'lang_dir' with an extension of ".yml".

The 'use_core' option will load the built-in language set. 'use_core_only' will not attempt to load anything except the built-in set.

If the load fails, an exception is thrown.


The rpls attribute accesses the loaded RPL List::Objects::WithUtils::Hash:

  my $this_str = $language->rpls->get($rpl) // "Missing RPL $rpl";


The spec attribute returns the SPEC: definition for the loaded language set.


Jon Portnoy <>