/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
examples/plugins/todo-example/admin/src/utils/prefixPluginTranslations.js
23 строки
642 B
Alexandre Bodin
chore: improve admin panel DX & add more advance plugin example
09 сен 2024, 12:11
09 сен 2024, 12:11
bceb8fa
Код
Авторство
О чём код?
/** * @typedef {Object.<string, string>} TradOptions */ /** * Prefixes the keys of the translation object with the plugin ID. * * @param {TradOptions} trad - The translation object. * @param {string} pluginId - The plugin ID to prefix. * @returns {TradOptions} - The new translation object with prefixed keys. * @throws {TypeError} - If the pluginId is empty. */ export function prefixPluginTranslations(trad, pluginId) { if (!pluginId) { throw new TypeError("pluginId can't be empty"); } return Object.keys(trad).reduce((acc, current) => { acc[`${pluginId}.${current}`] = trad[current]; return acc; }, {}); }