Project

General

Profile

Actions

Feature #1687

closed

GetText code inspection

Added by Serg Dvoriancev over 13 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Low
Assignee:
-
Category:
-
Target version:
-
Start date:
07/15/2011
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:

Description

In some cases, you can find such code:

$myname = 'NameName';
$myvar = 'abcd123';
$mytext = gettext("This is {$myname} have value {$myvar1}");

The gettext never translate this text. The variables change keyString each time.
Probably best way use sprintf
$mytext = sprintf(gettext("This is $s have value $s"), $myname, $myvsr1);

In this case GetText keyString is constant and can be translated.

PS Construction as
$mytext = gettext("This is ") . $myname . gettext("have value ") . $myvar1;
less effective because a short key string can cause a conflict of meaning translation in different places of project

Actions

Also available in: Atom PDF