dongxi8297 2017-04-06 13:37
浏览 115

Gettext会产生很多错误(页面完全坏了)

I want to Internationalize my website, so I have download gettext librairie (I work on my localhost and I have disable gettext module).

I followed a tutorial is the translation works :

But all my website is completely broken when I use /?lang=en_US.

Google chrome errors :

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/mysite/index.php/assets/bootstrap/css/bootstrap.min.css".
localhost/:11 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/mysite/index.php/assets/fonts/font-awesome/css/font-awesome.min.css".
localhost/:12 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/mysite/index.php/assets/stylesheets/custom.css".
?lang=en_US:13 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/mysite/index.php/assets/stylesheets/media-queries.css".
jquery-1.11.3.min.js:2 Uncaught SyntaxError: Unexpected token <
bootstrap.min.js:2 Uncaught SyntaxError: Unexpected token <
?lang=en_US:97 Uncaught ReferenceError: $ is not defined
    at ?lang=en_US:97
(anonymous) @ ?lang=en_US:97
?lang=en_US:142 Uncaught ReferenceError: $ is not defined
    at ?lang=en_US:142
(anonymous) @ ?lang=en_US:142
?lang=en_US:138 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/mysite/index.php/assets/stylesheets/dataTables.bootstrap.min.css".
jquery.dataTables.min.js:2 Uncaught SyntaxError: Unexpected token <
dataTables.bootstrap.min.js:2 Uncaught SyntaxError: Unexpected token <
dataTables.datesorting.js:2 Uncaught SyntaxError: Unexpected token <

This is my localization file :

<?php 
error_reporting(E_ALL | E_STRICT);

// define constants
define('PROJECT_DIR', realpath('./'));
define('LOCALE_DIR', PROJECT_DIR .'/locale');
define('DEFAULT_LOCALE', 'fr_FR');

require_once('./librairies/gettext/gettext.inc');

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

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

// gettext setup
T_setlocale(LC_MESSAGES, $locale);
// Set the text domain as 'messages'
$domain = 'traduction';
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);

header("Content-type: text/html; charset=$encoding");
?>

And here is a part of my index file :

<?php require_once __DIR__.'/localization.php'; ?>

<!DOCTYPE html>
<html lang="fr" class="no-js">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <title><?php echo $title; ?> - Mysite</title>

    <link rel="stylesheet" href="./assets/bootstrap/css/bootstrap.min.css">
    ....
    <script src="./assets/javascripts/bootstrap/bootstrap.min.js"></script>
  </head>

  <body>
<h1><?php echo _("BIENVENUE !"); ?></h1>
<h1><?php echo _("maison"); ?></h1>

Can you help me to resolve this ?

Thank you

  • 写回答

1条回答 默认 最新

  • duanci1939 2017-04-06 14:06
    关注

    Your link to css have error. I think the name of page index.php cause this error:

    http://localhost/mysite/index.php/assets/stylesheets/dataTables.bootstrap.min.css
    
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码