react-native/local-cli/link/android/patches/applyParams.js

19 lines
516 B
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const toCamelCase = require('lodash').camelCase;
module.exports = function applyParams(str, params, prefix) {
return str.replace(/\$\{(\w+)\}/g, (pattern, param) => {
const name = toCamelCase(prefix) + '_' + param;
return params[param] ? `getResources().getString(R.string.${name})` : null;
});
};