_locale_add_language

Versions
4.6 – 5
_locale_add_language($code, $name, $onlylanguage = TRUE)

Helper function to add a language

▾ 2 functions call _locale_add_language()

locale_admin_import in modules/locale.module
Page handler for the translation import screen
locale_admin_manage_add in modules/locale.module
Page handler for the language addition screen

Code

includes/locale.inc, line 14

<?php
function _locale_add_language($code, $name, $onlylanguage = TRUE) {
  db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s','%s')", $code, $name);
  $result = db_query("SELECT lid FROM {locales_source}");
  while ($string = db_fetch_object($result)) {
    db_query("INSERT INTO {locales_target} (lid, locale) VALUES (%d,'%s')", $string->lid, $code);
  }

  // If only the language was added, and not a PO file import triggered
  // the language addition, we need to inform the user on how to start
  // a translation
  if ($onlylanguage) {
    $message = t('%locale language added. You can now import a translation. See the <a href="%locale-help">help screen</a> for more information.', array('%locale' => theme('placeholder', t($name)), '%locale-help' => url('admin/help/locale')));
  }
  else {
    $message = t('%locale language added.', array('%locale' => theme('placeholder', t($name))));
  }

  drupal_set_message($message);
  watchdog('locale', t('%language language (%locale) added.', array('%language' => theme('placeholder', $name), '%locale' => theme('placeholder', $code))));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.