Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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 具有较大文本的Gettext()_Php_Gettext - Fatal编程技术网

Php 具有较大文本的Gettext()

Php 具有较大文本的Gettext(),php,gettext,Php,Gettext,我正在使用gettext()翻译我网站上的一些文本。大多数是短文本/按钮,如“后退”、“姓名” 我的问题是,这个文本(id)在echo gettext(“”)部分可以有多长时间 这会减缓长文本的处理速度吗?或者它也能正常工作?例如: echo _("LZ adfadffs is a VVV contributor who writes a weekly column for Cv00m. The former Hechinger Institute Fellow has had his comm

我正在使用gettext()翻译我网站上的一些文本。大多数是短文本/按钮,如“后退”、“姓名”

我的问题是,这个文本(id)在echo gettext(“”)部分可以有多长时间

这会减缓长文本的处理速度吗?或者它也能正常工作?例如:

echo _("LZ adfadffs is a VVV contributor who writes a weekly column for Cv00m. The former Hechinger Institute Fellow has had his commentary recognized by the Online News Association, the National Association of Black Journalists and the National ");
函数gettext

它被定义为字符串输入,因此您的机器内存将是限制因素

如果您的开发机器上有microtime或更好的xdebug,请尝试使用microtime对其进行基准测试。

该官员仅给出以下建议:

可翻译字符串应限于一段;不要让一条信息超过十行。原因是当可翻译字符串发生更改时,翻译器将面临更新整个已翻译字符串的任务。也许英语字符串中只有一个单词发生了变化,但翻译人员看不到(使用当前的翻译工具),因此她必须校对整个信息

对字符串的长度没有官方限制,它们显然可以超过至少“一段/10行”


对于长字符串,实际上应该没有可测量的性能损失。

gettext有效地限制了字符串长度4096个字符

当您超过此限制时,您将收到警告:

Warning: gettext(): msgid passed too long in %s on line %d
并返回
bool(false)
而不是文本

来源:

好的,所以一段或十行已经相当长了(在我的例子中)。我想知道“长字符串”是40-50个单词还是短字符串,比如5-10个单词。所以,如果我做对了,50个字应该不是什么大问题。
Warning: gettext(): msgid passed too long in %s on line %d