/**
  * Add i18n files from the given javascript directory.  Sapphire expects that the given directory
  * will contain a number of java script files named by language: en_US.js, de_DE.js, etc.
  * @param $langDir The javascript lang directory, relative to the site root, e.g., 'sapphire/javascript/lang'
  */
 public function add_i18n_javascript($langDir)
 {
     if (i18n::get_js_i18n()) {
         // Include i18n.js even if no languages are found.  The fact that
         // add_i18n_javascript() was called indicates that the methods in
         // here are needed.
         $this->javascript(SAPPHIRE_DIR . '/javascript/i18n.js');
         if (substr($langDir, -1) != '/') {
             $langDir .= '/';
         }
         $this->javascript($langDir . i18n::default_locale() . '.js');
         $this->javascript($langDir . i18n::get_locale() . '.js');
         // Stub i18n implementation for when i18n is disabled.
     } else {
         $this->javascript[SAPPHIRE_DIR . '/javascript/i18nx.js'] = true;
     }
 }
Exemplo n.º 2
0
 /**
  * Add i18n files from the given javascript directory.  SilverStripe expects that the given directory
  * will contain a number of java script files named by language: en_US.js, de_DE.js, etc.
  * 
  * @param String The javascript lang directory, relative to the site root, e.g., 'framework/javascript/lang'
  * @param Boolean Return all relative file paths rather than including them in requirements
  * @param Boolean Only include language files, not the base libraries
  */
 public function add_i18n_javascript($langDir, $return = false, $langOnly = false)
 {
     $files = array();
     if (i18n::get_js_i18n()) {
         // Include i18n.js even if no languages are found.  The fact that
         // add_i18n_javascript() was called indicates that the methods in
         // here are needed.
         if (!$langOnly) {
             $files[] = FRAMEWORK_DIR . '/javascript/i18n.js';
         }
         if (substr($langDir, -1) != '/') {
             $langDir .= '/';
         }
         $files[] = $langDir . i18n::default_locale() . '.js';
         $files[] = $langDir . i18n::get_locale() . '.js';
         // Stub i18n implementation for when i18n is disabled.
     } else {
         if (!$langOnly) {
             $files[] = FRAMEWORK_DIR . '/javascript/i18nx.js';
         }
     }
     if ($return) {
         return $files;
     } else {
         foreach ($files as $file) {
             $this->javascript($file);
         }
     }
 }