Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda