@difizen/mana-core
Version:
31 lines (27 loc) • 997 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.localize = localize;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/**
* Localize a message.
*
* `message` can contain `{n}` notation where it is replaced by the nth value in `...args`
* For example, `localize({ key: 'sayHello', comment: ['Welcomes user'] }, 'hello {0}', name)`
*/
/**
* Localize a message.
*
* `message` can contain `{n}` notation where it is replaced by the nth value in `...args`
* For example, `localize('sayHello', 'hello {0}', name)`
*/
function localize(key, message) {
if (typeof key === 'string') {
return key + message;
}
return key.comment + message;
}