dongtaochan0777 2011-07-06 05:51
浏览 51
已采纳

网站的多语言支持

While trying to modify eyeos install index page to support multi language using gettext method, i was unable to resolve an issue with the index page.

ISSUE:

The index page has 4 steps

It is possible to change the front page to the language we choose

but when i try to click next step it shows the default language rather than the choosen one

and also report an error as "Undefined index: submit in /var/www/html/install/index.php on line 78"

How can i resolve it...

the index.php file is

      <?php
        ob_start();
            if(!isset($_GET['step'])) 
            {
            $step = 'introduction';
           }  
           else 
           {
            $step = basename($_GET['step']);
           }
           require_once('steps/'.$step.'.php');
         echo '<?xml version="1.0" encoding="UTF-8" ?>';
           ?>
             <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
             <link rel="stylesheet" type="text/css" media="all" href="style.css"/>
     <title>eyeOS 2 installation</title>
 </head>
 <body>

<form action="" method="post">
    <select name="language">
    <option value="en">English</option>
    <option value="es">Spanish</option>
    </select>
    <input type="submit" name="submit" value="change language"/>
</form>

        <div id="wrapper" class="wrapper">
            <div id="topbar" class="topbar">
                <img src="logo-eyeos.png" id="logo" class="logo" />
                <div id="logotext" class="logotext">
                    <? echo toptext(); ?>
                </div>
            </div>
            <span id="sidebar" class="sidebar">
                <ul class="sidelist">
                    <?php

                        if ($_POST['submit'])
                        {
                            bindtextdomain('messages', './');
                            textdomain('messages');

                            $lang=$_POST['language'];

                            if ($lang)
                            {

                                switch ($lang) 
                                {
                                    case 'es':
                                        putenv('LC_ALL=es_ES'); 
                                        setlocale(LC_ALL,'es_ES');
                                        break;
                                    case 'en':
                                    default:
                                        setlocale(LC_ALL,'en_GB');
                                        break;
                                }
                            }               


                        if($step == 'introduction') {
                            echo _('<li class="selected">Introduction</li>');
                        } else {
                            echo _('<li>Introduction</li>');
                        }

                        if($step == 'requirements') {
                            echo _('<li class="selected">Requirements</li>');
                        } else {
                            echo _('<li>Requirements</li>');
                        }
                        if($step == 'configuration') {
                            echo _('<li class="selected">Configuration</li>');
                        } else {
                            echo _('<li>Configuration</li>');
                        }

                        if($step == 'end') {
                            echo _('<li class="selected">End</li>');
                        } else {
                            echo _('<li>End</li>');
                        }
                        }  

                    ?>
                </ul>
            </span>
            <span id="content" class="content">
                  <?php getContent(); ?>
            </span>
        </div>
</body>

and i edited some line in messages.po file

Lines are

1."Content-Type: text/plain; charset=UTF-8 "

2.

: index.php:81

msgid "Introduction" msgstr "Introducción"

: index.php:83

msgid "

Introduction" msgstr "Introducción"

3.

: index.php:87

msgid "Requirements" msgstr "Requisitos"

: index.php:89

msgid "

Requirements" msgstr "Requisitos"

4.

: index.php:92

msgid "Configuration" msgstr "Configuración"

: index.php:94

msgid "

Configuration" msgstr "Configuración"

5.

: index.php:98

msgid "End" msgstr "Final"

: index.php:100

msgid "

End" msgstr "Final"

2.#: index.php:81 msgid "Introduction" msgstr "Introducción"

: index.php:83

msgid "

Introduction" msgstr "Introducción"
  • 写回答

1条回答 默认 最新

  • 普通网友 2011-07-06 08:58
    关注

    To fix the error you report, and also report an error as "Undefined index: submit in /var/www/html/install/index.php on line 78", change:

    if ($_POST['submit'])
    

    to:

    if (isset($_POST['submit']))
    

    2nd issue:

    I would add some debugging to your code to see what the result of $_POST['language'] is. Maybe you aren't catching the language properly in your switch

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀