#!/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; # Load the Catalyst config my $tt_config = Config::ZOMG->new( name => "TopTable" ); my $config_hash = $tt_config->load; # Load the locales from the config my (@locales, %inheritance, $config); $config = $config_hash->{I18N}{locales}; foreach my $locale (keys %$config) { push(@locales, $locale); $inheritance{$locale} = $config->{$locale}{inherits} if defined $config->{$locale}{inherits}; } # Get the directory where the messages are defined my $dir = Path::Class::Dir->new( "$Bin/..", "root", "locale" ); # Load the lexicon TopTable::Maketext->load_lexicon( locales => \@locales, directories => [$dir], gettext_style => 1, inheritance => \%inheritance, ); my $lang = TopTable::Maketext->get_handle( "en_GB" ); printf "%s\n", $lang->maketext( "menu.title.league-tables", "Division Three" ); 1; #### package TopTable::Maketext; use strict; use warnings; use parent qw(CatalystX::I18N::Maketext); 1; #### use utf8; package TopTable::Schema; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE use Moose; use MooseX::MarkAsMethods autoclean => 1; extends 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; # Created by DBIx::Class::Schema::Loader v0.07037 @ 2013-12-03 11:04:44 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uMxbZipkwEqVJYByeZhY5Q # You can replace this text with custom code or comments, and it will be preserved on regeneration __PACKAGE__->meta->make_immutable(inline_constructor => 0); 1; #### use utf8; package TopTable::Schema; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE use Moose; use MooseX::MarkAsMethods autoclean => 1; extends 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; # Created by DBIx::Class::Schema::Loader v0.07037 @ 2013-12-03 11:04:44 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uMxbZipkwEqVJYByeZhY5Q use FindBin qw( $Bin ); use TopTable::Maketext; has "lang" => ( is => "ro", isa => "TopTable::Maketext", builder => "_set_maketext", required => 1, ); sub _set_maketext { my ( $self ) = @_; my $class = $self->class; my $app = $self->_app; my (@locales, %inheritance); my $config = $app->config->{I18N}{locales}; $app->log->debug( sprintf( "app: %s, class: %s", $app, $class ) ); printf( "app: %s, class: %s", $app, $class ); foreach my $locale (keys %$config) { push(@locales, $locale); $inheritance{$locale} = $config->{$locale}{inherits} if defined $config->{$locale}{inherits}; } my $dir = Path::Class::Dir->new( "$Bin/..", "root", "locale" ); TopTable::Maketext->load_lexicon( locales => \@locales, directories => [$dir], gettext_style => 1, inheritance => \%inheritance, ); return TopTable::Maketext->get_handle( "en_GB" ); } # You can replace this text with custom code or comments, and it will be preserved on regeneration __PACKAGE__->meta->make_immutable(inline_constructor => 0); 1; #### [error] Caught exception in TopTable::Controller::Admin::Bans->process_form "Can't call method "maketext" on an undefined value at D:\Personal\Dev\Web\www.mkttl.co.uk\TopTable\lib/TopTable/Schema/ResultSet/Ban.pm line 88."