| 1 | package Silki::Schema::Locale; | ||
| 2 | { | ||
| 3 | $Silki::Schema::Locale::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use DateTime::Locale; | ||
| 11 | use Silki::Schema; | ||
| 12 | |||
| 13 | use Fey::ORM::Table; | ||
| 14 | |||
| 15 | my $Schema = Silki::Schema->Schema(); | ||
| 16 | |||
| 17 | { | ||
| 18 | has_policy 'Silki::Schema::Policy'; | ||
| 19 | |||
| 20 | has_table( $Schema->table('Locale') ); | ||
| 21 | |||
| 22 | has_many countries => ( | ||
| 23 | table => $Schema->table('Country'), | ||
| 24 | order_by => [ $Schema->table('Country')->column('name'), 'ASC' ], | ||
| 25 | ); | ||
| 26 | } | ||
| 27 | |||
| 28 | sub CreateDefaultLocales { | ||
| 29 | my $class = shift; | ||
| 30 | |||
| 31 | for my $code ( DateTime::Locale->ids() ) { | ||
| 32 | next if $class->new( locale_code => $code ); | ||
| 33 | |||
| 34 | $class->insert( locale_code => $code ); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | __PACKAGE__->meta()->make_immutable(); | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | # ABSTRACT: Represents a locale | ||
| 43 | |||
| 44 | __END__ |