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

88
Views
llamando a un objeto json agregando una variable a la ruta

¿Es posible cambiar data.en.translation.test en algo como esto: data.language.translation.test;

Tengo un archivo json con varios objetos de lenguaje.

``

 { "en": { "translation": { "test": "some string" } }, "no": { "translation": { "test": "litt tekst" } } }

`` a continuación, tengo un script en el archivo html que contiene un objeto

``

 window._conf = { widgets: { main: { theme: "dark", lang: "en", debug: true, i18n: "i18n.json", }

`` Y el último archivo contiene una función que cambia el texto H1 dependiendo de la configuración de idioma en el objeto window._conf

``

 var survey_face = ` <h1 id="b"></h1><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;border-spacing:0;border:0;" width="100%"> <tbody> <tr>...

``

``

 var language = window._conf.widgets.main.lang; function newString(newtext) { fetch("i18n.json") .then((response) => response.json()) .then((data) => { newtext = data.language.translation.test; console.log(newtext); console.log(); b.innerHTML = newtext; }); } newString();

``

En resumen, necesito cargar el idioma de los lugares h1 según el idioma configurado en window._conf, sustituyéndolo desde el archivo i18n.json.

Gracias de antemano.

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!