Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Apache gettext windows无法工作/转换_Php_Windows_Apache_Gettext - Fatal编程技术网

Php Apache gettext windows无法工作/转换

Php Apache gettext windows无法工作/转换,php,windows,apache,gettext,Php,Windows,Apache,Gettext,我是新手 以下是我的设置: /Apache 2.2 PHP 5.3.6 Windows 7/ 我在Apache/htdocs/test/index.php中有以下代码 <?php $language = 'de_DE'; $translatefile = 'messages'; setlocale(LC_ALL, $language); putenv("LANG=".$language); bindtextdomain($translatefi

我是新手

以下是我的设置: /Apache 2.2 PHP 5.3.6 Windows 7/

我在Apache/htdocs/test/index.php中有以下代码

<?php
    $language = 'de_DE'; 
    $translatefile = 'messages'; 
    setlocale(LC_ALL, $language);
    putenv("LANG=".$language); 
    bindtextdomain($translatefile, 'C:/locale'); 
    textdomain($translatefile); 

    echo gettext("Hello World!");
?>
控制台中显示的结果是

Hall Welt!

我不知道为什么它不能与Apache一起工作。

这个问题不是用传统的方法解决的。我不得不使用PHPGetext而不是默认内置在php中的gettext(php_gettext.dll)

详情:

1) 从此处下载php gettext: 2) 将以下文件添加到index.php所在的文件夹中: -gettext公司 -gettext.php -streams.php 3) 这是新的index.php

  <?php
    error_reporting(E_ALL | E_STRICT);

    // define constants
    define('PROJECT_DIR', realpath('./'));
    define('LOCALE_DIR', 'C:/locale');
    define('DEFAULT_LOCALE', 'de_DE');

    require_once('gettext.inc');

    $supported_locales = array('en_US', 'sr_CS', 'de_CH');
    $encoding = 'UTF-8';

    $locale = (isset($_GET['lang']))? $_GET['lang'] : DEFAULT_LOCALE;

    //var_dump($locale);die();

    // gettext setup
    T_setlocale(LC_MESSAGES, $locale);
    // Set the text domain as 'messages'
    $domain = 'messages';
    bindtextdomain($domain, LOCALE_DIR);
    // bind_textdomain_codeset is supported only in PHP 4.2.0+
    if (function_exists('bind_textdomain_codeset')) 
      bind_textdomain_codeset($domain, $encoding);
    textdomain($domain);

    echo gettext("Hello World!");
    ?> 

访问
http://localhost/test
您将看到
霍尔贴边

我今天在WAMPServer2.2、Apache2.2Windows7、64位上遇到了同样的问题。我卸载了它并安装了32位。它起作用了

  <?php
    error_reporting(E_ALL | E_STRICT);

    // define constants
    define('PROJECT_DIR', realpath('./'));
    define('LOCALE_DIR', 'C:/locale');
    define('DEFAULT_LOCALE', 'de_DE');

    require_once('gettext.inc');

    $supported_locales = array('en_US', 'sr_CS', 'de_CH');
    $encoding = 'UTF-8';

    $locale = (isset($_GET['lang']))? $_GET['lang'] : DEFAULT_LOCALE;

    //var_dump($locale);die();

    // gettext setup
    T_setlocale(LC_MESSAGES, $locale);
    // Set the text domain as 'messages'
    $domain = 'messages';
    bindtextdomain($domain, LOCALE_DIR);
    // bind_textdomain_codeset is supported only in PHP 4.2.0+
    if (function_exists('bind_textdomain_codeset')) 
      bind_textdomain_codeset($domain, $encoding);
    textdomain($domain);

    echo gettext("Hello World!");
    ?> 
  ;extension=php_gettext.dll