[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3163] trunk/LedgerSMB/Initiate.pm



Revision: 3163
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3163&view=rev
Author:   einhverfr
Date:     2011-05-22 22:26:40 +0000 (Sun, 22 May 2011)

Log Message:
-----------
Ian's patch 2945474

Modified Paths:
--------------
    trunk/LedgerSMB/Initiate.pm

Modified: trunk/LedgerSMB/Initiate.pm
===================================================================
--- trunk/LedgerSMB/Initiate.pm	2011-05-22 22:22:02 UTC (rev 3162)
+++ trunk/LedgerSMB/Initiate.pm	2011-05-22 22:26:40 UTC (rev 3163)
@@ -8,6 +8,8 @@
 use LedgerSMB::Locale;
 use Data::Dumper;
 use DBI;
+use Locale::Language;
+use Locale::Country;
 use LedgerSMB::Log;
 
 my $logger = Log::Log4perl->get_logger('LedgerSMB::Initiate');
@@ -302,11 +304,36 @@
 		#Stage -  Wind up completed the task
 	process_roles($form);
 
+        #Stage 5 - Load languages
+    load_languages($form);
+
     $logger->debug("End LedgerSMB::Initiate::save_database");
 }
 
+sub load_languages {
+    $logger->debug("Beging LedgerSMB::Initiate::load_languages");
+    my ($form) = @_;
 
+    opendir DIR, $LedgerSMB::Sysconfig::localepath;
+    foreach my $dir (grep !/^\.\.?$/, readdir DIR) {
+        my $code = substr( $dir, 0, -3);
+        $logger->debug("add language $code");
+        my $description = code2language( substr( $code, 0, 2) );
+        $description .= '/' . code2country( substr( $code, 3, 2) ) if(length($code) > 4);
+        $description .= ' ' . substr( $code, 5 ) if(length($code) > 5);
+        $form->{dbh}->do("insert into language ( code, description ) values ( " .
+			$form->{dbh}->quote( $code ) . ', ' .
+            $form->{dbh}->quote( $description ) . ')'
+        ) || $form->error( __FILE__ . ':' . __LINE__ . ': '
+                  . $locale->text( 'language [_1]/[_2] creation failed',
+                      $code, $description));
+    }
+    closedir(DIR);
+    $logger->debug("End LedgerSMB::Initiate::load_languages");
+}
 
+
+
 sub process_roles {
 
     $logger->debug("Begin LedgerSMB::Initiate::process_roles");


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.