Vue18n with Element UI Form Validate

Hi everyone. I am using vue i18n to show different languages. But i do not know how to use vue i18n variables with js variables. Here is my code: (src message path also true. When i am using inside html it is working)

var validateEmail = (rule, value, callback) => {
            if (value === '') {
                callback(new Error($t('src.views.apps.errorMessages.enterEmail')));
            } else {
                if (this.yoneticiForm.eposta2 !== '') {
                    this.$refs.yoneticiForm.validateField('email2');
                }
                callback();
            }
        };

This code does not show any error messages. But in this way code is working.
callback(new Error("Please Enter Email"));

How to send vue18n variable to callback message?

a) (value === '') will only match empty strings, not null or undefined.
b) I presume you have a translation object similar to this registered?

const messages = {
 en { // <-- language key
    src: { // <-- start of a massive namespace object
      views: {
        apps: {
          errorMessages: {
            enterEmail: "Please provide an e-mail address.",
          }
        }
      }
    }
  }

c) and $t must be within the scope of validateEmail() or vice versa

Yes, i have same object like b. I tried to do check email is entered or not. But the message may be in different languages. And i do not want to write if statements.
And yes $t is a global variable that I defined in main.js.

Your “base core language” need to be complete.
If a message is not translated to the active locale, i.e “zh” or “fr”, it should find a fallback to the base, i.e “en” and get the key and value from there.

There could be a typo in the messages object, some wrong nesting. As you said,there is much more code and logic involved than just this snippet, that could interfere.

Simply try a console.log($t('src.views.apps.errorMessages.enterEmail')) before validateEmail to learn if that message translates at all, let alone running through a callback hell.
Put it inside the template as a string (why even throw an Error?)
You may also put a debugger statement inside that function and trace the outcome in DevTools.
:man_shrugging: