You are here

function _locale_add_language in Drupal 4

Same name and namespace in other branches
  1. 5 includes/locale.inc \_locale_add_language()

Helper function to add a language

2 calls to _locale_add_language()
locale_add_language_form_submit in includes/locale.inc
Process the language addition form submission.
_locale_admin_import_submit in includes/locale.inc
Process the locale import form submission.

File

includes/locale.inc, line 14
Admin-related functions for locale.module.

Code

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, translation) 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) {
    drupal_set_message(t('The language %locale has been created, and can now be used to import a translation. More information is available in the <a href="%locale-help">help screen</a>.', array(
      '%locale' => theme('placeholder', t($name)),
      '%locale-help' => url('admin/help/locale'),
    )));
  }
  else {
    drupal_set_message(t('The language %locale has been created.', array(
      '%locale' => theme('placeholder', t($name)),
    )));
  }
  watchdog('locale', t('The %language language (%locale) has been created.', array(
    '%language' => theme('placeholder', $name),
    '%locale' => theme('placeholder', $code),
  )));
}