Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Select a translation from certain locale based on parameter passed alongside with key in vue-i18n

I want to implement the following logic of translating Action message:

If source (second parameter passed to $t -- mainPage in the example bellow) is specified it then should try to get a translation from currentLocale.key.source path. If source key (mainPage) was not found or it is null I want to show the key itself ('Action') to a user.

Messages structure:

{
 'by': {
      'Action': {
         'menu': 'Дзеянне',
         'mainPage': 'Аперацыя'
      }
   }
}

mainPage.vue

{{ $t('Action', 'mainPage') }}

One could say that this is the same to $t('Action.mainPage') but in case of undefined translation it will show 'Action.mainPage' which is a no go for me.

I was trying to achieve the same with named-formatting. There is a potential but doesn't seem like a good option as it looks more as hack rather than a solution.

My guess is that $t should be overridden to implement this, but I couldn't figure out how.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!