internationalization/localization, RT12515
authorlevinse <levinse>
Fri, 3 Jun 2011 22:47:20 +0000 (22:47 +0000)
committerlevinse <levinse>
Fri, 3 Jun 2011 22:47:20 +0000 (22:47 +0000)
FS/FS/Conf.pm
FS/FS/Msgcat.pm

index 186d828..eaa6a3d 100644 (file)
@@ -4458,6 +4458,18 @@ and customer address. Include units.',
     'description' => 'An alternate ordering of fields for the New Customer and Edit Customer screens.',
     'type'        => 'checkbox',
   },
+  
+  {
+    'key'         => 'translate-auto-insert',
+    'section'     => '',
+    'description' => 'Auto-insert untranslated strings for selected non-en_US locales with their default/en_US values. DO NOT TURN THIS ON.',
+    'type'        => 'select-sub',
+    'multiple'    => 1,
+    'options_sub' => sub { map { $_ => '' } 
+                            grep { $_ ne 'en_US' } FS::Locales::locales;
+                                    },
+    'option_sub'  => sub { ''; },
+  },
 
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index e111f4e..2429805 100644 (file)
@@ -74,6 +74,18 @@ sub _gettext {
     warn "WARNING: message for msgcode $msgcode in locale $locale not found"
       unless $locale eq 'en_US';
     $cache{$locale}->{$msgcode} = $msgcode;
+
+    my @translate_auto_insert = $conf->config('translate-auto-insert');
+    if ( $locale ne 'en_US' && grep { $_ eq $locale } @translate_auto_insert ) {
+
+        # :(
+        my $newmsgcat = new FS::Record('msgcat', { locale     => $locale,
+                                         msgcode    => $msgcode,
+                                         msg        => $msgcode,
+                                       });
+        warn "WARNING: auto-inserting message for msgcode $msgcode in locale $locale";
+        $newmsgcat->insert;
+    }
   }
 
 }