[英]adding a leading and trailing space in wordpress php
I use this bit of code: 我使用以下代码:
<ul class="login-links">
<li>
<a href="/wp-login.php?redirect_to=<?php echo $_SERVER['REQUEST_URI']; ?>" class="simplemodal-login"><?php printf(__("Login"))?></a>
<span id="space-login-string"><?php printf(__(" or "));?></span>
<a href="/wp-login.php?action=register" class="simplemodal-register"><?php printf(__("Register"))?></a>
</li>
</ul>
It is a part of a sentence which has to be translated by WPML. 它是句子的一部分,必须由WPML翻译。
It should look like this: LOGIN OR REGISTER 它应该看起来像这样:登录或注册
Does anyone know why the leading and trailing space is trimmed and therefor looks like this: LOGINORREGISTER 有谁知道为什么要修剪前后空间,因此看起来像这样:LOGINORREGISTER
It has to be something simple but, stupid me, I can't find it. 它必须很简单,但是,愚蠢的我,我找不到它。 Please help.
请帮忙。
There are two possibilities: 有两种可能性:
__()
might trim the output or input on its own. __()
可能会自行修剪输出或输入。 IMHO, the spaces should not be inside the string which is to be translated, since only "or" needs a translation and making sure that the spaces are inserted is not the translators job. 恕我直言,空格不应位于要翻译的字符串中,因为只有“或”需要翻译,并且确保插入的空格不是翻译人员的工作。
Edit: As it turned out, the problem was that the three elements Login, or, and Register are floated left. 编辑:事实证明,问题在于三个元素Login,or和Register向左浮动。 This causes the spaces to be ignored.
这将导致空格被忽略。
To keep the spaces while keeping the three elements in one line, give all three elements display: inline;
为了在将三个元素保持在一行中的同时保留空间,请对所有三个元素进行
display: inline;
instead of the floating. 而不是浮动。
You should refer to the I18n for WordPress Developers docs . 您应该参考I18n for WordPress Developers文档 。 The right way of doing this with
printf()
would be: 使用
printf()
实现此目的的正确方法是:
printf( __( 'LOGIN %d REGISTER.', 'your-text-domain' ), 'or' );
There are a lot of other ways you could also do it, such as using _e()
or __()
. 您还可以通过许多其他方式来执行此操作,例如使用
_e()
或__()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.