<template>
  <a-config-provider :locale="locale" v-bind="$attrs">
    <slot />
  </a-config-provider>
</template>

<script>
import components from './_import-components/sd-config-provider-import'

/**
 * 与 a-config-provider 功能相同，加上了自动适配浏览器语言的功能
 * @displayName SdConfigProvider 全局化配置
 * @since 0.22
 */
export default {
  name: 'SdConfigProvider',
  components,
  inheritAttrs: false,
  data() {
    return {
      locale: undefined,
    }
  },
  created() {
    const i18nModule = this.$t ? import('@/i18n') : import('@/i18n/fallback')
    i18nModule
      .then((module) => module.loadAntdLocale)
      .then((loadAntdLocale) => loadAntdLocale())
      .then((data) => (this.locale = data))
  },
  methods: {},
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
