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

165
Visualizações
Inserting a variable into a string

I want to localize a json object by variable. For this I want to insert a html given variable into a json path as string.

I have a json file with a list of actors

"actors":{
    "Pete":{
      "status": "dead",
    },
    "Anna":{
      "status": "alive",
    },
    "Hans":{
      "status": "alive",
    },
    "Fred":{
      "status": "somewhat alive",
    }}

This file is used for foundryvtt as language file.

Now I want to access the data of the users by using the json path with their html handlebar.

{{localize 'actors.Pete.status'}}

which pushes the json path as string to a method which returns the json element.

This works perfectly and outputs: dead

Now I am trying to input a variable into the path. Which would look something like this:

{{localize 'actors.Variable.status'}}

My problem is, that the Variable is called similar as the json element:

{{user.name}}

which would output one of the names in the list, of course inputting this directly into the handlebar doesn't work.

{{localize 'actors.{{user.name}}.status'}}

I would love a simple and lightweight solution to this problem. Or some comments on my solution ;)

At the moment I am using some script with their java handlebar.

<input id="lan-name" name="name" type="text" value= "{{user.name}}" placeholder="Missing Translation for {{user.name}}"/>
<script>
   document.getElementById("lan-name").value = game.i18n.localize("actors.{{user.name}}.status");
</script>

But I only analyse code patterns and barely understand them. Happy about any comments and pointers. Thanks in advance :D

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