UNPKG

baseui

Version:

A React Component library implementing the Base design language

17 lines (15 loc) 592 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getInterpolatedString; /* Copyright (c) Uber Technologies, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. */ // Example: // getInterpolatedString('Selected date is ${date}', 'Jan 1, 2020') => 'Selected date is Jan 1, 2020' function getInterpolatedString(translation, interpolations = {}) { return translation.replace(/\${(.*?)}/g, (_, k) => interpolations[k] === undefined ? '${' + k + '}' : interpolations[k]); }