UNPKG

press-ui

Version:

简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目

42 lines (30 loc) 865 B
const { hyphenate, } = require('./generate-entry'); const { PATH_MAP, saveJsonToFile } = require('./helper'); function getTitleI18nConfig(componentConfig) { const res = { 'zh-CN': {}, 'en-US': {}, }; Object.keys(componentConfig) .forEach((key) => { const value = componentConfig[key]; const { list, name, title } = value; res['zh-CN'][name] = title; res['en-US'][name] = name; list.forEach((item) => { const hyphenatedName = hyphenate(item.name); res['zh-CN'][hyphenatedName] = `${item.name} ${item.title}`; res['en-US'][hyphenatedName] = `${item.name}`; }); }); return res; } function writeDemoTitleI18n(componentConfig) { const title = getTitleI18nConfig(componentConfig); saveJsonToFile(PATH_MAP.DEMO_I18N, title); } module.exports = { writeDemoTitleI18n, };