UNPKG

444 BJavaScriptView Raw
1import { i18n } from '../config';
2
3/**
4 * Mark a label as translatable.
5 *
6 * @param {string} key Translation key to be leveraged by the consumer to provide a generic translation at configuration time.
7 * @param {string} defaultValue A fallback value to be relied on if the consumer doesn't have translation capabilities.
8 * @returns {string} The translated label.
9 */
10export const translate = (key, defaultValue) => i18n[key] ?? defaultValue;