vee-validate and vue-i18n integration when using custom ruleVue JS 2.0 not rendering anything?Dynamic localization in vue-i18nvue-i18n doesn't update locale after integrating vuexVuejs 2: Unable to switch between tabbed formVueJS validation change locale during runtimeVue.js vee-validate custom dictionary setupHow to use Vuex state when creating custom validation with Vee ValidateImport library on local and call the library function on global to make validationUse I18n translation messages from SFC when using Vue.extendVue-i18n Integration by vee-validate not working as described in the documentation

What should you do when eye contact makes your subordinate uncomfortable?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

How can "mimic phobia" be cured or prevented?

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?

Mixing PEX brands

Did arcade monitors have same pixel aspect ratio as TV sets?

How does a computer interpret real numbers?

Can I visit Japan without a visa?

Is aluminum electrical wire used on aircraft?

Can a College of Swords bard use a Blade Flourish option on an opportunity attack provoked by their own Dissonant Whispers spell?

Angel of Condemnation - Exile creature with second ability

What is going on with 'gets(stdin)' on the site coderbyte?

How do you make your own symbol when Detexify fails?

How does the math work for Perception checks?

How to cover method return statement in Apex Class?

How to hide some fields of struct in C?

Does Doodling or Improvising on the Piano Have Any Benefits?

The IT department bottlenecks progress. How should I handle this?

Biological Blimps: Propulsion

Are Captain Marvel's powers affected by Thanos' actions in Infinity War

How could a planet have erratic days?

How much character growth crosses the line into breaking the character

What should you do if you miss a job interview (deliberately)?

Mimic lecturing on blackboard, facing audience



vee-validate and vue-i18n integration when using custom rule


Vue JS 2.0 not rendering anything?Dynamic localization in vue-i18nvue-i18n doesn't update locale after integrating vuexVuejs 2: Unable to switch between tabbed formVueJS validation change locale during runtimeVue.js vee-validate custom dictionary setupHow to use Vuex state when creating custom validation with Vee ValidateImport library on local and call the library function on global to make validationUse I18n translation messages from SFC when using Vue.extendVue-i18n Integration by vee-validate not working as described in the documentation













0















This is a question about the integration of vee-validate and vue-i18n + additional error message for a custom rule. I could get every single detail to work alone, but not the whole combination (this is the excuse for the long question).



The program flow is as follows:



  1. A web page containing vue.js component loads from server. The vue.js component loads vee-validate and vue-i18n and defines a custom rule. It does not pre-load any language data - so on created() it checks the language of the container web page and loads it's localized texts from the server via ajax call.


  2. It is straightforward to set these messages to the vue-i18n simply so:



    this.$i18n.mergeLocaleMessage(localeName, newLocaleMessages)



  3. Somehow I have to tell vee-validate to change its language also ...
    I want to load the corresponding vee-validate locale with its default error messages


and



I want to add my custom error message translation to the validation messages.



And here I have the problems



While it is possible to pre-load all needed vee-validate localisations like so:



import en from 'vee-validate/dist/locale/en'
...
import de from 'vee-validate/dist/locale/de'
...
Vue.use(VeeValidate,
i18nRootKey: 'validations',
i18n,
dictionary:
en: en
...
de: de

)


I do not want to do it as it does not make sense to load multile data if the component won't use it.



It is better to load the data dynamically.



And if one does not use vue-i18n it works perfectly like that:



if (this.$validator.dictionary.hasLocale(localeName)) 
this.$validator.localize(localeName);
else
import(`vee-validate/dist/locale/$localeName`).then(locale =>
this.$validator.localize(localeName, locale);
);


/from ajax/ -> custom_dictionary =
/localeName/ :
messages:
customMessage: "TRanslation in /localeName/"


;

this.$validator.localize(custom_dictionary);


But then I want to use vue-i18n. So this.$validator... does not work anymore.
One also has to load the default language explicitly:



Vue.use(VeeValidate, 
i18nRootKey: 'validations',
i18n,
dictionary:
en: en

)


and when I try:



import(`vee-validate/dist/locale/$localeName`).then(locale => {
this.$i18n.mergeLocaleMessage(localeName, locale)
or
this.$i18n.mergeLocaleMessage(localeName, locale.messages)
or
this.$i18n.mergeLocaleMessage(localeName, locale.default.messages)


it does not work (the corresponding object in $i18n is created but stays empty).



Is there another syntax that would work?



It is somehow awkward that one cannot just call a method like $validator.loadLanguage(localeName).then(set it to i18n).



One also cannot define by the custom rule something like:



getMessage : () => get the message from $i18n using this key 


as the getMessage function is called only once with the currently loaded language.



Another restriction is that the message key should be the name of the custom rule - so every time I get it from the API I have to create new object with that name and pass it to the vv validator to localize it (put it in the corrsponding dictionary).



So at the end I actually cannot understand what is the profit to use vee-validate integrated with $i18n? I would consider to use them just separately. Or where am I wrong?



Any ideas for flawless integration are much appreciated. Thanks in advance!










share|improve this question


























    0















    This is a question about the integration of vee-validate and vue-i18n + additional error message for a custom rule. I could get every single detail to work alone, but not the whole combination (this is the excuse for the long question).



    The program flow is as follows:



    1. A web page containing vue.js component loads from server. The vue.js component loads vee-validate and vue-i18n and defines a custom rule. It does not pre-load any language data - so on created() it checks the language of the container web page and loads it's localized texts from the server via ajax call.


    2. It is straightforward to set these messages to the vue-i18n simply so:



      this.$i18n.mergeLocaleMessage(localeName, newLocaleMessages)



    3. Somehow I have to tell vee-validate to change its language also ...
      I want to load the corresponding vee-validate locale with its default error messages


    and



    I want to add my custom error message translation to the validation messages.



    And here I have the problems



    While it is possible to pre-load all needed vee-validate localisations like so:



    import en from 'vee-validate/dist/locale/en'
    ...
    import de from 'vee-validate/dist/locale/de'
    ...
    Vue.use(VeeValidate,
    i18nRootKey: 'validations',
    i18n,
    dictionary:
    en: en
    ...
    de: de

    )


    I do not want to do it as it does not make sense to load multile data if the component won't use it.



    It is better to load the data dynamically.



    And if one does not use vue-i18n it works perfectly like that:



    if (this.$validator.dictionary.hasLocale(localeName)) 
    this.$validator.localize(localeName);
    else
    import(`vee-validate/dist/locale/$localeName`).then(locale =>
    this.$validator.localize(localeName, locale);
    );


    /from ajax/ -> custom_dictionary =
    /localeName/ :
    messages:
    customMessage: "TRanslation in /localeName/"


    ;

    this.$validator.localize(custom_dictionary);


    But then I want to use vue-i18n. So this.$validator... does not work anymore.
    One also has to load the default language explicitly:



    Vue.use(VeeValidate, 
    i18nRootKey: 'validations',
    i18n,
    dictionary:
    en: en

    )


    and when I try:



    import(`vee-validate/dist/locale/$localeName`).then(locale => {
    this.$i18n.mergeLocaleMessage(localeName, locale)
    or
    this.$i18n.mergeLocaleMessage(localeName, locale.messages)
    or
    this.$i18n.mergeLocaleMessage(localeName, locale.default.messages)


    it does not work (the corresponding object in $i18n is created but stays empty).



    Is there another syntax that would work?



    It is somehow awkward that one cannot just call a method like $validator.loadLanguage(localeName).then(set it to i18n).



    One also cannot define by the custom rule something like:



    getMessage : () => get the message from $i18n using this key 


    as the getMessage function is called only once with the currently loaded language.



    Another restriction is that the message key should be the name of the custom rule - so every time I get it from the API I have to create new object with that name and pass it to the vv validator to localize it (put it in the corrsponding dictionary).



    So at the end I actually cannot understand what is the profit to use vee-validate integrated with $i18n? I would consider to use them just separately. Or where am I wrong?



    Any ideas for flawless integration are much appreciated. Thanks in advance!










    share|improve this question
























      0












      0








      0








      This is a question about the integration of vee-validate and vue-i18n + additional error message for a custom rule. I could get every single detail to work alone, but not the whole combination (this is the excuse for the long question).



      The program flow is as follows:



      1. A web page containing vue.js component loads from server. The vue.js component loads vee-validate and vue-i18n and defines a custom rule. It does not pre-load any language data - so on created() it checks the language of the container web page and loads it's localized texts from the server via ajax call.


      2. It is straightforward to set these messages to the vue-i18n simply so:



        this.$i18n.mergeLocaleMessage(localeName, newLocaleMessages)



      3. Somehow I have to tell vee-validate to change its language also ...
        I want to load the corresponding vee-validate locale with its default error messages


      and



      I want to add my custom error message translation to the validation messages.



      And here I have the problems



      While it is possible to pre-load all needed vee-validate localisations like so:



      import en from 'vee-validate/dist/locale/en'
      ...
      import de from 'vee-validate/dist/locale/de'
      ...
      Vue.use(VeeValidate,
      i18nRootKey: 'validations',
      i18n,
      dictionary:
      en: en
      ...
      de: de

      )


      I do not want to do it as it does not make sense to load multile data if the component won't use it.



      It is better to load the data dynamically.



      And if one does not use vue-i18n it works perfectly like that:



      if (this.$validator.dictionary.hasLocale(localeName)) 
      this.$validator.localize(localeName);
      else
      import(`vee-validate/dist/locale/$localeName`).then(locale =>
      this.$validator.localize(localeName, locale);
      );


      /from ajax/ -> custom_dictionary =
      /localeName/ :
      messages:
      customMessage: "TRanslation in /localeName/"


      ;

      this.$validator.localize(custom_dictionary);


      But then I want to use vue-i18n. So this.$validator... does not work anymore.
      One also has to load the default language explicitly:



      Vue.use(VeeValidate, 
      i18nRootKey: 'validations',
      i18n,
      dictionary:
      en: en

      )


      and when I try:



      import(`vee-validate/dist/locale/$localeName`).then(locale => {
      this.$i18n.mergeLocaleMessage(localeName, locale)
      or
      this.$i18n.mergeLocaleMessage(localeName, locale.messages)
      or
      this.$i18n.mergeLocaleMessage(localeName, locale.default.messages)


      it does not work (the corresponding object in $i18n is created but stays empty).



      Is there another syntax that would work?



      It is somehow awkward that one cannot just call a method like $validator.loadLanguage(localeName).then(set it to i18n).



      One also cannot define by the custom rule something like:



      getMessage : () => get the message from $i18n using this key 


      as the getMessage function is called only once with the currently loaded language.



      Another restriction is that the message key should be the name of the custom rule - so every time I get it from the API I have to create new object with that name and pass it to the vv validator to localize it (put it in the corrsponding dictionary).



      So at the end I actually cannot understand what is the profit to use vee-validate integrated with $i18n? I would consider to use them just separately. Or where am I wrong?



      Any ideas for flawless integration are much appreciated. Thanks in advance!










      share|improve this question














      This is a question about the integration of vee-validate and vue-i18n + additional error message for a custom rule. I could get every single detail to work alone, but not the whole combination (this is the excuse for the long question).



      The program flow is as follows:



      1. A web page containing vue.js component loads from server. The vue.js component loads vee-validate and vue-i18n and defines a custom rule. It does not pre-load any language data - so on created() it checks the language of the container web page and loads it's localized texts from the server via ajax call.


      2. It is straightforward to set these messages to the vue-i18n simply so:



        this.$i18n.mergeLocaleMessage(localeName, newLocaleMessages)



      3. Somehow I have to tell vee-validate to change its language also ...
        I want to load the corresponding vee-validate locale with its default error messages


      and



      I want to add my custom error message translation to the validation messages.



      And here I have the problems



      While it is possible to pre-load all needed vee-validate localisations like so:



      import en from 'vee-validate/dist/locale/en'
      ...
      import de from 'vee-validate/dist/locale/de'
      ...
      Vue.use(VeeValidate,
      i18nRootKey: 'validations',
      i18n,
      dictionary:
      en: en
      ...
      de: de

      )


      I do not want to do it as it does not make sense to load multile data if the component won't use it.



      It is better to load the data dynamically.



      And if one does not use vue-i18n it works perfectly like that:



      if (this.$validator.dictionary.hasLocale(localeName)) 
      this.$validator.localize(localeName);
      else
      import(`vee-validate/dist/locale/$localeName`).then(locale =>
      this.$validator.localize(localeName, locale);
      );


      /from ajax/ -> custom_dictionary =
      /localeName/ :
      messages:
      customMessage: "TRanslation in /localeName/"


      ;

      this.$validator.localize(custom_dictionary);


      But then I want to use vue-i18n. So this.$validator... does not work anymore.
      One also has to load the default language explicitly:



      Vue.use(VeeValidate, 
      i18nRootKey: 'validations',
      i18n,
      dictionary:
      en: en

      )


      and when I try:



      import(`vee-validate/dist/locale/$localeName`).then(locale => {
      this.$i18n.mergeLocaleMessage(localeName, locale)
      or
      this.$i18n.mergeLocaleMessage(localeName, locale.messages)
      or
      this.$i18n.mergeLocaleMessage(localeName, locale.default.messages)


      it does not work (the corresponding object in $i18n is created but stays empty).



      Is there another syntax that would work?



      It is somehow awkward that one cannot just call a method like $validator.loadLanguage(localeName).then(set it to i18n).



      One also cannot define by the custom rule something like:



      getMessage : () => get the message from $i18n using this key 


      as the getMessage function is called only once with the currently loaded language.



      Another restriction is that the message key should be the name of the custom rule - so every time I get it from the API I have to create new object with that name and pass it to the vv validator to localize it (put it in the corrsponding dictionary).



      So at the end I actually cannot understand what is the profit to use vee-validate integrated with $i18n? I would consider to use them just separately. Or where am I wrong?



      Any ideas for flawless integration are much appreciated. Thanks in advance!







      javascript vue.js vuejs2 vee-validate vue-i18n






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      Alexander MihailovAlexander Mihailov

      14329




      14329






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280860%2fvee-validate-and-vue-i18n-integration-when-using-custom-rule%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280860%2fvee-validate-and-vue-i18n-integration-when-using-custom-rule%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현