UNPKG

@opra/common

Version:
17 lines (16 loc) 607 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.translate = translate; const string_utils_js_1 = require("./string-utils.js"); const bracketRegEx = /(\))/g; function translate(key, arg0, arg1) { const options = arg0 && typeof arg0 === 'object' ? arg0 : undefined; const fallback = typeof arg0 === 'string' ? arg0 : arg1; return ('$t(' + key + (options ? ',' + JSON.stringify(options) : '') + (fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') + ')'); }