@nutui/nutui
Version:
京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
18 lines (17 loc) • 569 B
JavaScript
import locale from "@nutui/nutui/dist/packages/locale/lang";
import { g as getPropByPath, i as isFunction } from "./util-D1pvnUYu.js";
const useLocale = (name = "") => {
return (keyPath, ...args) => {
name = name.toLocaleLowerCase();
const languages = locale.languages();
let text = keyPath;
if (name && name.startsWith("nut")) {
text = `${name.slice(3)}.${keyPath}`;
}
const res = getPropByPath(languages, text) || getPropByPath(languages, keyPath);
return isFunction(res) ? res(...args) : res;
};
};
export {
useLocale as u
};