0

PHP

$this->data['months'] = array();

    for ($i = 1; $i <= 12; $i++) {
        $this->data['months'][] = array(
            'text'  => strftime('%B', mktime(0, 0, 0, $i, 1, 2000)), 
            'value' => sprintf('%02d', $i)
        );

$_['months'][]        = array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");

HTML

<select name="cc_expire_date_month">
                    <option value="01">January</option>
                    <option value="02">February</option>
                    <option value="03">March</option>
                    <option value="04">April</option>
                    <option value="05">May</option>
                    <option value="06">June</option>
                    <option value="07">July</option>
                    <option value="08">August</option>
                    <option value="09">September</option>
                    <option value="10">October</option>
                    <option value="11">November</option>
                    <option value="12">December</option>
                  </select>

我无法更改月份的语言。我应该将 $_['months'][] 更改为什么?再次需要太多细节,请帮助我无法更改该表单选择元素的语言

4

2 回答 2

0

将您的 html 放入 php 中,然后创建会话变量语言:

if(isset($_SESSION["language"])){
    if($_SESSION["language"]=="EN"){
    include_once("languages/languageEN.php");
    }
    if($_SESSION["language"]=="WHATEVER"){
    include_once("languages/languageWHATEVER.php");
    }
}else{
    include_once("languages/languageEN.php");
}

              <select name="cc_expire_date_month">
                <option value="01"><?php echo MONTH1; ?></option>
                <option value="02"><?php echo MONTH2; ?></option>
                <option value="03"><?php echo MONTH3; ?></option>
                <option value="04"><?php echo MONTH4; ?></option>
                <option value="05"><?php echo MONTH5; ?></option>
                <option value="06"><?php echo MONTH6; ?></option>
                <option value="07"><?php echo MONTH7; ?></option>
                <option value="08"><?php echo MONTH8; ?></option>
                <option value="09"><?php echo MONTH9; ?></option>
                <option value="10"><?php echo MONTH10; ?></option>
                <option value="11"><?php echo MONTH11; ?></option>
                <option value="12"><?php echo MONTH12; ?></option>
              </select>

在 languageEN.php 或 languageWHATEVER.php 上:

<?php
    define('MONTH_1','January');
    define('MONTH_2','February');
    define('MONTH_3','March');
    define('MONTH_4','April');
    define('MONTH_5','May');
    define('MONTH_6','June');
    define('MONTH_7','July');
    define('MONTH_8','August');
    define('MONTH_9','September');
    define('MONTH_10','October');
    define('MONTH_11','November');
    define('MONTH_12','December');
?>
于 2013-09-12T16:42:53.360 回答
0
$weird_months=array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");

$this->data['months'] = array();

    for ($i = 1; $i <= 12; $i++) {
        $this->data['months'][] = array(
            'text'  => $weird_months[$i-1], 
            'value' => sprintf('%02d', $i)
        );
于 2013-09-12T16:35:39.387 回答