Author: peter
Date: Sun Sep 20 14:08:22 2009
New Revision: 3442

Log:
change EAD i18n import logic to accept ISO639-1 language codes as a fallback 
option

Modified:
   trunk/lib/QubitXmlImport.class.php

Modified: trunk/lib/QubitXmlImport.class.php
==============================================================================
--- trunk/lib/QubitXmlImport.class.php  Sun Sep 20 14:08:07 2009        (r3441)
+++ trunk/lib/QubitXmlImport.class.php  Sun Sep 20 14:08:22 2009        (r3442)
@@ -170,32 +170,29 @@
         {
           $isocode = trim(preg_replace('/[\n\r\s]+/', ' ', 
$language->nodeValue));
           // convert to Symfony culture code
-          if ($twoCharCode = strtolower($langCodeConvertor->getID2($isocode)))
+          if (!$twoCharCode = strtolower($langCodeConvertor->getID2($isocode)))
           {
-            // Check to make sure that the selected language is supported with 
a Symfony i18n data file.
-            // If not it will cause a fatal error in the Language List 
component on every response.
-            try
-            {
-              format_language($twoCharCode, $twoCharCode);
-            }
-            catch (Exception $e)
-            {
-              $qubitXmlImport->errors[] = __('EAD "langmaterial" is set 
to').': "'.$isocode.'". '.__('This language is currently not supported.');
-              continue;
-            }
-
-            if ($currentCulture !== $twoCharCode)
-            {
-              $qubitXmlImport->errors[] = __('EAD "langmaterial" is set 
to').': "'.format_language($twoCharCode, $twoCharChode).'". '.__('Your XML 
document has been saved in this language and your user interface has just been 
switched to this language.');
-            }
-            $sf_user->setCulture($twoCharCode);
-            // can only set to one language, so have to break once the first 
valid language is encountered
-            break;
+            $twoCharCode = $isocode;
           }
-          else
+          // Check to make sure that the selected language is supported with a 
Symfony i18n data file.
+          // If not it will cause a fatal error in the Language List component 
on every response.
+          try
+          {
+            format_language($twoCharCode, $twoCharCode);
+          }
+          catch (Exception $e)
           {
             $qubitXmlImport->errors[] = __('EAD "langmaterial" is set to').': 
"'.$isocode.'". '.__('This language is currently not supported.');
+            continue;
+          }
+
+          if ($currentCulture !== $twoCharCode)
+          {
+            $qubitXmlImport->errors[] = __('EAD "langmaterial" is set to').': 
"'.$isocode.'" ('.format_language($twoCharCode, 'en').'). '.__('Your XML 
document has been saved in this language and your user interface has just been 
switched to this language.');
           }
+          $sf_user->setCulture($twoCharCode);
+          // can only set to one language, so have to break once the first 
valid language is encountered
+          break;
         }
       }
     }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to