UNPKG

@hackplan/polaris

Version:

Shopify’s product component library

21 lines (20 loc) 659 B
import { get } from '../../../../utilities/get'; import merge from '../../../../utilities/merge'; import translate from './translate'; export default class Intl { constructor(translation) { this.translation = translation; this.translate = (id, replacements) => { return translate(id, this.translation, replacements); }; this.setTranslation(translation); } setTranslation(translation) { this.translation = Array.isArray(translation) ? merge(...translation) : translation; } translationKeyExists(path) { return Boolean(get(this.translation, path)); } }