1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = getInterpolatedString;
|
7 |
|
8 | /*
|
9 | Copyright (c) 2018-2020 Uber Technologies, Inc.
|
10 |
|
11 | This source code is licensed under the MIT license found in the
|
12 | LICENSE file in the root directory of this source tree.
|
13 | */
|
14 | // Example:
|
15 | // getInterpolatedString('Selected date is ${date}', 'Jan 1, 2020') => 'Selected date is Jan 1, 2020'
|
16 | function getInterpolatedString(translation) {
|
17 | var interpolations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
18 | return translation.replace(/\${(.*?)}/g, function (_, k) {
|
19 | return interpolations[k] === undefined ? '${' + k + '}' : interpolations[k];
|
20 | });
|
21 | } |
\ | No newline at end of file |