hi folks,
in the "strings.txt", that is located under "./locale/en_GB/", appear in templates for messages various dynamic place holder like '%s', '{%1}'.
could anybody explain me how they can be used or where i can find futher Inforamtion (mapping etc.) about this feature?
background: i'd like to customize/overwrite some of them in "custom_strings.txt".
we use TestLink 1.9.14
thank you for your assistance
regards
yury
usage of dynamic place holder in "strings.txt"
Moderators: Amaradana, TurboPT, TL Developers
Re: usage of dynamic place holder in "strings.txt"
Though the original post is now several months old, I'll show a high-level basic example use of each, below, for informational reference for those that might not be familiar with the syntax/usage...
The %s is used with certain print-format functions, such as sprintf().
=========
An example with the [function argument/parameter] numbers %1, %2, etc:
From en_GB/strings.txt:
...then in file login.php, we can find:
...the portion of interest is the first parameter to logAuditEvent() which is a call to TLS().
TLS is passed a string reference along with the login and IP address. The login ultimately replaces %1 and the IP address replaces the %2 to complete the string.
The TLS() definition is in file: /lib/functions/metastring.class.php. Look there to see how the arguments are gathered.
===========
Now a %s example:
From en_GB/strings.txt:
...we can find that string being used in file: /lib/requirements/reqSpecView.php
...so to the sprintf, the first function argument is the string [which contains the %s format], and the second function argument is what replaces the %s to complete the string.
HTH.
The %s is used with certain print-format functions, such as sprintf().
- Know that there are other "format specifiers" available, not only %s.
- There are also other functions that use the specifiers in a similar manner. Refer to the "See Also" section in the above sprintf link.
=========
An example with the [function argument/parameter] numbers %1, %2, etc:
From en_GB/strings.txt:
Code: Select all
...
$TLS_audit_login_succeeded = "Login for '{%1}' from '{%2}' succeeded";
...
Code: Select all
// Login successful, redirect to destination
logAuditEvent(TLS("audit_login_succeeded",$argsObj->login,
$_SERVER['REMOTE_ADDR']),"LOGIN",$_SESSION['currentUser']->dbID,"users");
TLS is passed a string reference along with the login and IP address. The login ultimately replaces %1 and the IP address replaces the %2 to complete the string.
The TLS() definition is in file: /lib/functions/metastring.class.php. Look there to see how the arguments are gathered.
===========
Now a %s example:
From en_GB/strings.txt:
Code: Select all
...
$TLS_importViaAPI = "Import via API (%s)";
...
Code: Select all
...
$gui->btn_import_req_spec = sprintf(lang_get('importViaAPI'),$reqMgrSystem['reqmgrsystem_name']);
...
HTH.