Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:06:45+00:00 2026-06-08T12:06:45+00:00

We’re teaching a class in chinese (Mandarin). For our students, it would be easier

  • 0

We’re teaching a class in chinese (Mandarin). For our students, it would be easier (and make more sense to them) if the error output running php (on the commandline) was localizable to Mandarin. Is there a way to configure our php setup to support this (i.e. edit a php.ini file)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:06:46+00:00Added an answer on June 8, 2026 at 12:06 pm

    I have downloaded the PHP source code and searched how the source handles it’s errors. After going through a couple of (randomly picked) files and found these kinds of lines all over the place:

    // warning for the sleep() function
    php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of seconds must be greater than or equal to 0");
    
    // warning for the constant() function
    php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't find constant %s", const_name);
    
    // warning for the mysql_free_result() function
    php_error_docref("function.mysql-free-result" TSRMLS_CC, E_WARNING, "%lu result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()", MySG(result_allocated));
    
    // error for the mysql-escape-string function()
    php_error_docref("function.mysql-escape-string" TSRMLS_CC, E_DEPRECATED, "This function is deprecated; use mysql_real_escape_string() instead.");
    

    This goes on and on forever which makes me conclude that errors are hardcoded and thus not available in any other language…

    Too bad 🙁


    After hours of searching (5 hours and 45 minutes to be exact) – I have found a couple of solutions that probably aren’t worthwhile but who am I to judge.

    Translations are often saved in files with the .po extension. These files contain a bunch of original strings and the translated strings. This means that you have to translate every string each, manually. You can create files with PoEdit.

    Then you need to parse these files. You can build a PHP version that has the Gettext module installed. Alternatively, the Zend Framework is able to parse these files as well.

    Clearly, you don’t want to translate every possible string manually. Last option is using a translator service such as Google Translate or Microsoft Translate.

    In all cases, you have to replace the existing error string with the new error string. There’s a native PHP function called set_error_handler(). This allows you to set a custom error handling function. If you want to translate the existing error string you should do it there. Here’s a set up that you could use (I haven’t tested this thoroughly):

    <?php
    set_error_handler('error_handler');
    
    function error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
        // Get the correct string for the error type
        switch($errno){
            case E_ERROR:
                $type = 'Error';
                break;
            case E_WARNING:
                $type = 'Warning';
                break;
            case E_PARSE:
                $type = 'Parse Error';
                break;
            case E_NOTICE:
                $type = 'Notice';
                break;
            case E_CORE_ERROR:
                $type = 'Core Error';
                break;
            case E_CORE_WARNING:
                $type = 'Core Warning';
                break;
            case E_COMPILE_ERROR:
                $type = 'Compile Error';
                break;
            case E_COMPILE_WARNING:
                $type = 'Compile Warning';
                break;
            case E_USER_ERROR:
                $type = 'User Error';
                break;
            case E_USER_WARNING:
                $type = 'User Warning';
                break;
            case E_USER_NOTICE:
                $type = 'User Notice';
                break;
            case E_STRICT:
                $type = 'Strict Notice';
                break;
            case E_RECOVERABLE_ERROR:
                $type = 'Recoverable Error';
                break;
            default:
                $type = 'Unknown error (' . $errno . ')';
                break;
        }
    
        // translate text
        $type = error_handler_translate($type);
        $str = error_handler_translate($errstr);
        $in = error_handler_translate('in');
        $line = error_handler_translate('on line');
    
        // echo the error in "default" PHP format
        echo '<br /><b>'. $type .':</b> ' . $str . ' '. $in .' <b>' . $errfile . '</b> '. $line .' <b>' . $errline . '</b><br />';
    
        // ignore the original PHP error handling
        return true;
    }
    
    function error_handler_translate($str) {
        // translate $str here
    
        return $str;
    }
    ?>
    

    All that remains is including this code to your script and you should be all good!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.