Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Catalyst: accessing maketext from a model

by mkchris (Sexton)
on Jan 22, 2022 at 00:29 UTC ( [id://11140692]=note: print w/replies, xml ) Need Help??


in reply to Catalyst: accessing maketext from a model

Hi everyone - I have finally got my head around this - this is the code that eventually worked:
#!/usr/bin/perl use strict; use warnings; use FindBin qw( $Bin ); use lib "$Bin/../lib"; use Data::Dumper::Concise; use TopTable::Maketext; use Config::ZOMG; use Path::Class::Dir; my $tt_config = Config::ZOMG->new( name => 'TopTable' ); my $config_hash = $tt_config->load; my (@locales, %inhertiance, $config); $config = $config_hash->{I18N}{locales}; foreach my $locale (keys %$config) { push(@locales, $locale); $inhertiance{$locale} = $config->{$locale}{inherits} if defined $con +fig->{$locale}{inherits}; } my $dir = Path::Class::Dir->new( "$Bin/..", "root", "locale" ); TopTable::Maketext->load_lexicon( locales => \@locales, directories => [$dir], gettext_style => 1, inheritance => \%inhertiance, ); my $lang = TopTable::Maketext->get_handle( "en_GB" ); printf "%s\n", $lang->maketext( "menu.title.league-tables", "Division +Three" ); 1;
This gives the correct value of:
League Tables for Division Three
Thank you for putting up with me spamming here!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140692]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-26 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found