/**
  * @param $locale
  */
 public function __construct($locale = null)
 {
     $this->defaultLocale = $locale ? $locale : i18n::get_lang_from_locale(i18n::config()->get('default_locale'));
     $this->basePath = Director::baseFolder();
     $this->baseSavePath = Director::baseFolder();
     parent::__construct();
 }
 /**
  * Determines which language to use for jQuery UI, which
  * can be different from the value set in i18n.
  *
  * @return String
  */
 protected function getLang()
 {
     $locale = $this->getField()->getLocale();
     $map = $this->config()->locale_map;
     if ($this->getField()->getConfig('jslocale')) {
         // Undocumented config property for now, might move to the jQuery view helper
         $lang = $this->getField()->getConfig('jslocale');
     } else {
         if (array_key_exists($locale, $map)) {
             // Specialized mapping for combined lang properties
             $lang = $map[$locale];
         } else {
             // Fall back to default lang (meaning "en_US" turns into "en")
             $lang = i18n::get_lang_from_locale($locale);
         }
     }
     return $lang;
 }
 /**
  * Returns the script direction in format compatible with the HTML "dir" attribute.
  *
  * @see http://www.w3.org/International/tutorials/bidi-xhtml/
  * @param String $locale Optional locale incl. region (underscored)
  * @return String "rtl" or "ltr"
  */
 public static function get_script_direction($locale = null)
 {
     require_once 'Zend/Locale/Data.php';
     if (!$locale) {
         $locale = i18n::get_locale();
     }
     try {
         $dir = Zend_Locale_Data::getList($locale, 'layout');
     } catch (Zend_Locale_Exception $e) {
         $dir = Zend_Locale_Data::getList(i18n::get_lang_from_locale($locale), 'layout');
     }
     return $dir && $dir['characters'] == 'right-to-left' ? 'rtl' : 'ltr';
 }