@inkline/inkline
Version:
Inkline is the intuitive UI Components library that gives you a developer-friendly foundation for building high-quality, accessible, and customizable Vue.js 3 Design Systems.
9 lines (8 loc) • 392 B
JavaScript
import { getValueByPath, isFunction } from "@grozav/utils";
import { i18n } from "@inkline/inkline/i18n";
import { interpolate } from "@inkline/inkline/utils";
export function translate(path, scope = {}) {
const template = getValueByPath(i18n.messages[i18n.locale], path);
const string = (isFunction(template) ? template(scope) : template) || path;
return interpolate(string, scope);
}