Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda