Your best option is to use sprintf()
function. Then you would use printf
notation to handle dynamic content in your strings. Here is a function I found on here a while ago to handle this easily for you:
function translate()
{
$args = func_get_args();
$num = func_num_args();
$args[0] = gettext($args[0]);
if($num <= 1)
return $args[0];
return call_user_func_array('sprintf', $args);
}
Now for example 1, you would want to change the string to:
%s poked %s
Which you would input into the translate()
function like this:
<?php echo translate('%s poked %s', $user1, $user2); ?>
You would parse out all translate()
functions with poEdit. and then translate the string "%s poked %s"
into whatever language you wanted, without modifying the %s
string placeholders. Those would get replace upon output by the translate()
function with user1 and user2 respectively. You can read more on sprintf()
in the PHP Manual for more advanced usages.
For issue #2. You would need to create a static file which poEdit could parse containing the category names. For example misctranslations.php
:
<?php
_('Cars');
_('Trains');
_('Airplanes');
Then have poEdit parse misctranslations.php
. You would then be able to output the category name translation using <?php echo gettext($data['name']); ?>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…