コード例 #1
0
ファイル: LanguagesTableSeeder.php プロジェクト: kitbs/vinfo
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('languages')->delete();
     $languages = get_locales();
     //Config::get('translatable.locales');
     foreach ($languages as $language) {
         $language = ['code' => $language, 'name' => PunicLanguage::getName($language, $language)];
         Language::create($language);
     }
 }
コード例 #2
0
ファイル: CountriesTableSeeder.php プロジェクト: kitbs/vinfo
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('countries')->delete();
     $locales = Config::get('translatable.locales');
     // $locales = get_locales(true);
     $countries = Territory::getCountries('en');
     $producing = ['AL', 'AM', 'AR', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CN', 'CU', 'CY', 'CZ', 'DE', 'DZ', 'EE', 'EG', 'ES', 'ET', 'FR', 'GB', 'GE', 'GR', 'HR', 'HU', 'IL', 'IT', 'JO', 'JP', 'KG', 'KZ', 'LB', 'LI', 'LT', 'LU', 'LV', 'LY', 'MA', 'MD', 'ME', 'MG', 'MK', 'MT', 'MX', 'NZ', 'PA', 'PE', 'PT', 'PY', 'RE', 'RO', 'RS', 'RU', 'SI', 'SK', 'SY', 'TJ', 'TM', 'TN', 'TR', 'UA', 'US', 'UY', 'UZ', 'VN', 'ZA', 'ZW', 'CSHH', 'CSXX', 'SUHH', 'YUCS'];
     foreach ($countries as $code => $void) {
         $country = ['code' => $code, 'is_wine' => in_array($code, $producing)];
         $nameEn = Territory::getName($code, 'en');
         foreach ($locales as $key => $locale) {
             if (is_array($locale)) {
                 $country[$key] = ['name' => Territory::getName($code, $key)];
                 foreach ($locale as $countryLocale) {
                     $name = Territory::getName($code, $key . '-' . $countryLocale);
                     if ($name != $country[$key]['name'] && $name != $nameEn) {
                         $country[$key . '-' . $countryLocale] = ['name' => $name];
                     }
                 }
             } else {
                 $name = Territory::getName($code, $locale);
                 if ($name != $nameEn) {
                     $country[$locale] = ['name' => $name];
                 }
             }
         }
         $country = Country::create($country);
         $langs = Territory::getLanguages($code, 'of', true);
         $langs = array_map(function ($lang) {
             return str_replace('_', '-', $lang);
         }, $langs);
         $langs = array_diff($langs, get_locales(true));
         foreach ($langs as $lang) {
             $name = Territory::getName($code, str_replace('-', '_', $lang));
             $translation = $country->getNewTranslation($lang);
             $translation->name = $name;
             $translation->country_id = $country->id;
             $translation->save();
         }
     }
     $countries = ['CSHH' => 'Czechoslovakia', 'CSXX' => 'Serbia and Montenegro', 'SUHH' => 'Soviet Union', 'YUCS' => 'Yugoslavia'];
     foreach ($countries as $code => $name) {
         $country = ['code' => $code, 'is_wine' => in_array($code, $producing), 'en' => ['name' => $name]];
         $country = Country::create($country);
     }
 }
コード例 #3
0
ファイル: locale.php プロジェクト: nico13051995/IntITA
/**
 * Returns locale info by its code.
 *
 * It is a wrapper for {@link get_locales()} function and can be used to improve
 * readability of the code.
 *
 * @param string $locale
 * @return array|false Associative array of locale info or boolean false if the
 *   locale is unknown. See {@link get_locales()} description for details of the
 *   info array keys.
 */
function get_locale_info($locale)
{
    $locales = get_locales();

    return isset($locales[$locale]) ? $locales[$locale] : false;
}
コード例 #4
0
ファイル: monisetup.php プロジェクト: reviforks/moniwiki
function set_locale($lang, $charset = '')
{
    $supported = array('en_US' => array('ISO-8859-1'), 'fr_FR' => array('ISO-8859-1'), 'ko_KR' => array('EUC-KR', 'UHC'));
    if ($lang == 'auto') {
        # get broswer's settings
        $langs = get_locales();
        $lang = $langs[0];
        $charset = strtoupper($charset);
        # XXX
        $server_charset = '';
        if (function_exists('nl_langinfo')) {
            $server_charset = nl_langinfo(CODESET);
        }
        if ($charset == 'UTF-8') {
            if ($charset != $server_charset) {
                $lang .= "." . $charset;
            }
        } else {
            if ($supported[$lang] && in_array($charset, $supported[$lang])) {
                return $lang . '.' . $charset;
            } else {
                return 'en_US';
                // default
            }
        }
    }
    return $lang;
}
コード例 #5
0
require_once "./lib/defines.php";
require_once "./lib/module.access.php";
require_once "a2blib/Form.inc.php";
require_once "a2blib/Class.HelpElem.inc.php";
require_once "a2blib/Form/Class.SqlRefField.inc.php";
$menu_section = 'menu_config';
HelpElem::DoHelp(_("Mail templates are preset messages to be sent on alerts etc."));
$HD_Form = new FormHandler('cc_templatemail', _("Templates"), _("Template"));
$HD_Form->checkRights(ACX_MISC);
$HD_Form->init();
$PAGE_ELEMS[] =& $HD_Form;
$PAGE_ELEMS[] = new AddNewButton($HD_Form);
$HD_Form->model[] = new PKeyFieldEH(_("ID"), 'id');
$HD_Form->model[] = new TextFieldEH(_("Type"), 'mtype');
$HD_Form->model[] = new RefField(_("Lang"), 'lang', get_locales(true));
$HD_Form->model[] = dontList(new TextField(_("From Name"), 'fromname', _("Human name of sender")));
$HD_Form->model[] = new TextField(_("From"), 'fromemail', _("Email of sender"));
$HD_Form->model[] = new TextField(_("Subject"), 'subject');
$HD_Form->model[] = dontList(new TextAreaField(_("Message"), 'message', _("The message, arguments are %-quoted")));
$HD_Form->model[] = dontList(new TextAreaField(_("Default args."), 'defargs', _("Default values for arguments, in URL parameter format.")));
$HD_Form->model[] = new DelBtnField();
require_once "a2blib/Form/Class.ImportView.inc.php";
require_once "a2blib/Class.DynConf.inc.php";
$HD_Form->views['ask-import'] = new AskImportView();
$HD_Form->views['import-analyze'] = new ImportMailAView($HD_Form->views['ask-import']);
// $HD_Form->views['import'] = new ImportView($HD_Form->views['ask-import']);
//$HD_Form->views['ask-import']->common = array('idrp');
$HD_Form->views['ask-import']->csvmode = false;
$HD_Form->views['ask-import']->mandatory = array('mtype', 'lang', 'fromemail', 'subject', 'message');
$HD_Form->views['ask-import']->optional = array('fromname', 'defargs');
コード例 #6
0
ファイル: Updater.php プロジェクト: abhijitroy07/mibew
 /**
  * Performs all database updates needed for 2.1.0.
  *
  * @return boolean True if the updates have been applied successfully and
  * false otherwise.
  */
 protected function update20100()
 {
     $db = $this->getDatabase();
     if (!$db) {
         return false;
     }
     try {
         // Alter locale table.
         $db->query('ALTER TABLE {locale} ADD COLUMN name varchar(128) NOT NULL DEFAULT "" AFTER code');
         $db->query('ALTER TABLE {locale} ADD COLUMN rtl tinyint NOT NULL DEFAULT 0');
         $db->query('ALTER TABLE {locale} ADD COLUMN time_locale varchar(128) NOT NULL DEFAULT "en_US"');
         $db->query('ALTER TABLE {locale} ADD COLUMN date_format text');
         $db->query('ALTER TABLE {locale} ADD UNIQUE KEY code (code)');
         // Create a table for available updates.
         $db->query('CREATE TABLE {availableupdate} ( ' . 'id INT NOT NULL auto_increment PRIMARY KEY, ' . 'target varchar(255) NOT NULL, ' . 'version varchar(255) NOT NULL, ' . 'url text, ' . 'description text, ' . 'UNIQUE KEY target (target) ' . ') charset utf8 ENGINE=InnoDb');
         // Generate Unique ID of Mibew instance.
         $db->query('INSERT INTO {config} (vckey, vcvalue) VALUES (:key, :value)', array(':key' => '_instance_id', ':value' => Utils::generateInstanceId()));
     } catch (\Exception $e) {
         $this->errors[] = getlocal('Cannot update tables: {0}', $e->getMessage());
         return false;
     }
     try {
         // Store configs for available locales in the database.
         $locales = $db->query('SELECT localeid as id, code from {locale}', null, array('return_rows' => Database::RETURN_ALL_ROWS));
         $locales_info = get_locales();
         foreach ($locales as $row) {
             $id = $row['id'];
             $code = $row['code'];
             $info = (isset($locales_info[$code]) ? $locales_info[$code] : array()) + array('name' => $code, 'rtl' => false, 'time_locale' => 'en_US', 'date_format' => array('full' => '%d %B %Y, %H:%M', 'date' => '%d %B %Y', 'time' => '%H:%M'));
             $db->query('UPDATE {locale} SET ' . 'name = :name, rtl = :rtl, time_locale = :time_locale, ' . 'date_format = :date_format ' . 'WHERE localeid = :id', array(':id' => $id, ':name' => $info['name'], ':rtl' => $info['rtl'] ? 1 : 0, ':time_locale' => $info['time_locale'], ':date_format' => serialize($info['date_format'])));
         }
     } catch (\Exception $e) {
         $this->errors[] = getlocal('Cannot update content: {0}', $e->getMessage());
         return false;
     }
     return true;
 }
コード例 #7
0
ファイル: add_locale.php プロジェクト: alexbodea/globalnews
    foreach ($_POST as $key => $value) {
        $parts = explode('_', $key);
        $operation = $parts[0];
        $id = $parts[1];
        $slug = $parts[2];
        if ($parts[0] == 'update') {
            $value = $db->escape_string($value);
            $sql = $db->execute("UPDATE locale SET {$slug} = '{$value}' WHERE id = '{$id}'");
        }
    }
    $slugs_string = '';
    $slugs = $db->array_select("SELECT slug FROM slugs");
    foreach ($slugs as $slug) {
        $slugs_string .= $slug['slug'] . ',';
    }
    $slugs_string = substr($slugs_string, 0, -1);
    $index = 0;
    while (!empty($_POST['insert_' . $index . '_us'])) {
        $values_string = '';
        foreach ($slugs as $slug) {
            $values_string .= "'" . $_POST['insert_' . $index . '_' . $slug['slug']] . "',";
        }
        $values_string = substr($values_string, 0, -1);
        $sql = "INSERT INTO locale ({$slugs_string}) VALUES ({$values_string})";
        $db->execute($sql);
        $index++;
    }
    create_locales();
}
echo $twig->render('add_locale.html', array('active_menu' => 'add_locale', 'msg' => $msg, 'title_part' => 'Adăugare traduceri', 'utils' => $utils, 'slugs' => get_locales()));