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

322
Vistas
Cómo convertir un archivo .properties a un objeto json en reaccionar

Tengo un proyecto antiguo, usa algo llamado frase para traducciones.

De todos modos, nuestros archivos de traducción son * .properties y en reaccionar no pude encontrar una manera de manejarlos.

Por lo general, uso i18next para manejar archivos tranlsation.json en reaccionar

alguna idea de qué es lo mejor para manejar * .properties en reaccionar

un ejemplo sobre el archivo language.property

 header.shortcuts-screenreader=Listen header.shortcuts-sign-in=Sign in header.shortcuts-sign-out=Sign out header.shortcuts-my-pages=My pages header.shortcuts-new-to-the-library=New to the library? header.shortcuts-join-the-library=Join the library header.primary-navigation=Primary navigation

la salida es algo como esto:

 { "sessionTimer": { "accessibleTimingOut": "{{timeoutMinutes}} minutes until this page times out. Move your mouse pointer or press any key to extend the time with {{extendMinutes}} minutes.", "reload": "Reload", "timedOut": "The page has timed out and needs to be reloaded.", "timingOut": "seconds until this page times out and needs to be reloaded. Move your mouse pointer or press any key to extend the time with {{extendMinutes}} minutes." }, "header": { "screenReaderLabel": "Listen", "myAccountLabel": "Sign in", "myAccountLogoutLabel": "Sign out", "myAccountPagesLabel": "My pages", "newToTheLibrary": "New to the library?", "joinTheLibraryLabel": "Join the library", "openingsLabel": "Opening hours", "languageLabel": "Language" }, "branchOpeningHours": { "headerLabel": "Opening hours", "closedLabel": "Closed", "todayLabel": "Today", "navigationBackLabel": "Back", "navigationNextLabel": "Next", "navigationPreviousLabel": "Previous", "serviceTypeClosedLabel": "Closed", "serviceTypeStaffedLabel": "Staffed", "serviceTypeSelfServiceLabel": "Self-service", "typeRegularLabel": "Regular", "typeSpecialLabel": "Special", "viewAllLabel": "Show all opening hours" } }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Podrías hacer algo como lo siguiente

 const data = `header.shortcuts-screenreader=Listen header.shortcuts-sign-in=Sign in header.primary-navigation=Primary navigation footer.primary-link=Navigation footer.shortcuts-sign-out=Sign out`; const rows = data.split("\n").map((r) => { return { parent: r.split(".")[0], child: r.split(".")[1].split("=")[0], value: r.split(".")[1].split("=")[1] } }); const result = rows.reduce((acc, { parent, child, value }) => { // convert to child from xx to camel case const camelChild = child.split("-").map((c, i) => { return i === 0 ? c : c.charAt(0).toUpperCase() + c.slice(1, c.length) }).join(""); // if property doesn't exist yet on outcome object if (!acc[parent]) { // create new object & assign first value acc[parent] = { [camelChild]: value } return acc; // return early } // otherwise acc[parent][camelChild] = value; // assign value to property in object return acc; }, {}); console.log(result);

about 4 years ago · Juan Pablo Isaza Denunciar
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