Returning variable from response on the end of function in javascript [duplicate]

I have this function:

function settingTextLan(text) {
  fetch("i18n.json")
    .then((response) => response.json())
    .then((data) => {
      text = data[language].translation.test;
    });
  return text;
}
console.log(settingTextLan());

And i want return “text” in current location, But now i get “Undefined”. Later i will need to return few values that contains certain texts from JSON file and call them in different places.

How to do it to call that and have access in other places?