Files
ECShopX_admin-frontend/tailwind.plugins.lang-variants.js
2025-12-30 09:26:17 +08:00

16 lines
504 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Tailwind CSS 语言变体插件
* 支持基于 HTML lang 属性的变体例如en-CN:pt-4, zh-CN:pt-2
* 动态从 langMap 生成语言变体
*/
const { langMap } = require('./src/i18n/index.js')
module.exports = function ({ addVariant }) {
// 遍历 langMap动态生成语言变体
Object.values(langMap).forEach((langAttr) => {
// 为每个语言属性添加变体
// 当 HTML lang 属性匹配时应用样式
addVariant(langAttr, `html[lang="${langAttr}"] &`)
})
}