X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fmsgcat.pm;h=d1224f334deacd906f537a40788d0c01a37fa59a;hp=855b8b291368851b1766841c47b6a3975c8758e6;hb=90393980e5f2859ee1e186fa461f48f5129e803e;hpb=58d44fbe5eb9ab32e6d87063a4a3b22ddba9a828 diff --git a/FS/FS/msgcat.pm b/FS/FS/msgcat.pm index 855b8b291..d1224f334 100644 --- a/FS/FS/msgcat.pm +++ b/FS/FS/msgcat.pm @@ -4,7 +4,7 @@ use strict; use vars qw( @ISA ); use Exporter; use FS::UID; -use FS::Record qw( qsearchs ); +use FS::Record; # qw( qsearchs ); @ISA = qw(FS::Record); @@ -52,7 +52,8 @@ If you just want to B message catalogs, see L. =item new HASHREF -Creates a new example. To add the example to the database, see L<"insert">. +Creates a new message catalog entry. To add the message catalog entry to the +database, see L<"insert">. Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the I method. @@ -91,8 +92,8 @@ returns the error, otherwise returns false. =item check -Checks all fields to make sure this is a valid example. If there is -an error, returns the error, otherwise returns false. Called by the insert +Checks all fields to make sure this is a valid message catalog entry. If there +is an error, returns the error, otherwise returns false. Called by the insert and replace methods. =cut @@ -116,6 +117,39 @@ sub check { $self->SUPER::check } + +sub _upgrade_data { #class method + my( $class, %opts) = @_; + + eval "use FS::Setup;"; + die $@ if $@; + + #"repopulate_msgcat", false laziness w/FS::Setup::populate_msgcat + + my %messages = FS::Setup::msgcat_messages(); + + foreach my $msgcode ( keys %messages ) { + foreach my $locale ( keys %{$messages{$msgcode}} ) { + my %msgcat = ( + 'msgcode' => $msgcode, + 'locale' => $locale, + #'msg' => $messages{$msgcode}{$locale}, + ); + #my $msgcat = qsearchs('msgcat', \%msgcat); + my $msgcat = FS::Record::qsearchs('msgcat', \%msgcat); #wtf? + next if $msgcat; + + $msgcat = new FS::msgcat( { + %msgcat, + 'msg' => $messages{$msgcode}{$locale}, + } ); + my $error = $msgcat->insert; + die $error if $error; + } + } + +} + =back =head1 BUGS