in setup you can do as follows:
With ref:
//<script setup>
import { getCurrentInstance, ref } from "vue";
const currentLanguage = ref("en");
const app = getCurrentInstance();
app.appContext.config.globalProperties.$lang = () => {
return currentLanguage.value;
};
//</script>
With pinia:
//<script setup>
import { getCurrentInstance, reactive } from "vue";
import { storeToRefs } from "pinia";
import { useDataStore } from "@/stores/data";
const uiStore = useUiStore();
const { currentLanguage } = storeToRefs(uiStore);
const app = getCurrentInstance();
app.appContext.config.globalProperties.$lang = () => {
return currentLanguage.value;
};
//</script>
Regards