ftos.utils.getLocalizedString
IMPORTANT!
Starting with v24.3.0, this is renamed from getString to ftos.utils.getLocalizedString.
Starting with v24.3.0, this is renamed from getString to ftos.utils.getLocalizedString.
Returns a composite format string stored in a resource object corresponding to the current system language. Replaces any indexed placeholders in the returned string with arguments from a specified array.
This is a method suitable for all business service components.
Syntax
function ftos.utils.getLocalizedString(resource: any, arguments: any[]): string
| Parameter | Description |
|---|---|
resource
|
Resource object. Has the following structure:{
key : <Key Name>,
<locale 1>: <String 1>,
<locale 1>: <String 2>,
...
}The key entry is mandatory, although not used by the ftos.utils.getLocalizedString function.Strings may contain indexed placeholders based on the .NET format item syntax {index[,alignment][:formatString]}. For example: {0}, {1:d}, {0:hh}, {1:E}, {1,5:N1}. |
arguments
|
Array of replacement values for the placeholders in the resource string. |
Return Value
Returns the string matching the current system language, with replacement values in place of any indexed placeholders.
Examples
In this example:
- We generate an order confirmation message for order 223-vb290.
- We store the message template for the ro-RO and en-GB locales in the confirmation variable.
- We use placeholders for the order number {0} and the current date {1:d} and current time {1:t}.
var confirmation = {
key : 'confirmationMessage',
'ro-RO': 'Comanda {0} a fost recepționată pe data de {1:d}, la ora {1:t}.',
'en-GB': 'Order {0} was received on {1:d}, at {1:t}.'
}
message = ftos.utils.getLocalizedString(confirmation, ['223-vb290', new Date]);