79473400

Date: 2025-02-27 17:01:33
Score: 0.5
Natty:
Report link

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

Reasons:
  • Blacklisted phrase (1): Regards
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Anton Sychev