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

157
Vistas
Is it possible to change a certain string within an URL with another term using script?

Hi everyone.

I have a tumblr blog, whose navigation is organized in tags, forming URLs like these.

xxxx.com/home_english/

xxxx.com/home_spanish/

xxxx.com/news_english/

xxxx.com/news_english/chrono

xxxx.com/news_spanish/

xxxx.com/news_spanish/chrono

The blog has 2 links at the top that allow users to change the language of the blog. However, these links are static, pointing always to the homepage of the blog in the chosen language. 

My goal is to allow users to change the language any time while staying in the page that are currently visiting, being capable for example, and by clicking only the aforementioned links, to go directly from... 

xxxx.com/news_english/chrono to...
xxxx.com/news_spanish/chrono. 

I guess the script should then be able to grab the current URL, find the string associated with the language (always after the unique underscore of the URL, sometimes before the second dash after the domain, sometimes not), then substitute it by the target language and finally rebuild the URL.

That’s it. Thank you so much.

Regards

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After you've created an string out of your url as Simone said in his comment, you should find the ${pageName}_${languageName} word; Based on the details you've provided, you can do it like this:

// creating an string out of url; Note that you should define createUrlString function yourself
const urlString = createUrlString(url);

//finding the page_language word in the string
const wordsArray = urlString.split('/');
const pageLanguage = wordsArray.find(word => word.includes('_'))

After this step, you can easily change the 'pageLanguage' word by replacing current language with the selected one, and then replace it in the url string.

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