简体   繁体   English

如何在php中隐藏gettext信息

[英]How to hide gettext infos in php

I am writing simple script using gettext PHP function. 我正在使用gettext PHP函数编写简单的脚本。 All works well but i try to monitore what is changed for what. 一切都运作良好,但我试图monitore什么改变了什么。

For example when user change 2 fields 例如,当用户更改2个字段时

Type: (old) Agreement (new) Anex
Notes: (old) #empty field# (new) Agreement ID: 123

My editinfo generator looks like that 我的editinfo生成器看起来像那样

foreach($checkArray as $row => $value)
{
    if ($addData[$row] != $checkArray[$row])
    {
        $editInfo .= ' <b>' . _("FILED") . '</b> ' . _("$row") . ' <b>' . _("CHANGED FROM") . '</b> ' . _($checkArray[$row]) . ' <b>' . _("FOR") . '</b> ' . _($addData[$row]) . '<br />';
    }
}

But i recieved info like that 但我收到了这样的信息

<b>POLE</b> Type <b>ZMIENIONE Z</b> Umowa <b>NA</b> Aneks <br />
<b>POLE</b> Notes <b>ZMIENIONE Z</b> Project-Id-Version: 
POT-Creation-Date: 
PO-Revision-Date: 
Language-Team: 
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Generator: Poedit 2.0.9
Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);
Last-Translator: 
Language: pl
 <b>NA</b> Agreement ID: 123<br />

As You can see all translates works well, but when field is empty, gettext function return some crazy stuff but i would like to have 正如你可以看到所有翻译都运行良好,但当字段为空时,gettext函数返回一些疯狂的东西,但我想有

<b>Pole</b> Type <b>ZMIENIONE Z</b> Umowa <b>NA</b> Aneks<br>
<b>Pole</b> Notes <b>ZMIENIONE Z</b> <b>NA</b> Agreement ID: 123<br>

So my question is what i should to change in PHP or PHP Settings in my server to hide that gettext info. 所以我的问题是我应该在我的服务器中的PHP或PHP设置中更改以隐藏该gettext信息。 I would to set "If gettext can't find translation just write pure text" in this case nothing. 我想设置“如果gettext找不到翻译只写纯文本”,在这种情况下没什么。

Regards 问候

As we can read in gettext manual : 我们可以在gettext手册中阅读:

This also has another advantage, as the empty string in a PO file GNU gettext is usually translated into some system information attached to that particular MO file, and the empty string necessarily becomes the first in both the original and translated tables, making the system information very easy to find. 这也有另一个优点,因为PO文件GNU gettext中的空字符串通常被翻译成附加到该特定MO文件的一些系统信息,并且空字符串必然成为原始表和翻译表中的第一个,从而使系统信息很容易找到。

Probably your .po file contains msgid which is an empty string and its value is just the system information. 可能你的.po文件包含msgid ,这是一个空字符串,它的值只是系统信息。

So when you call _("") you get that. 所以当你打电话给_("")你会得到它。 You can try passing some default field if it's not found: 如果找不到,可以尝试传递一些默认字段:

_($checkArray[$row] ?: "default")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM