Internationalization of images

Asked

Viewed 44 times

-1

I have an HTML project that needs different images for each language.

The image is loaded into index.html with <img src="">. How to change the image according to the chosen language?

I tried that code:

"img1": { 
     "pt": '../img/img-pt.jpg',
     "en": '../img/img-en.jpg', 
}
  • depends on how you developed the system, if it is only html, I would create a select with both languages, and then create a javascript function to read this select and define which image to use.

  • @Lodi is using only html and js, with n18i.js which has text translation properties, but I tried unsuccessfully to use the same logic, as I explained in the question.

  • I’ve never heard of this n18i, but taking everything into consideration, I believe that what you should do is build a javascript function to change the images, as the language changes! do with Jquery you take the element, and change the src attribute to the desired!

1 answer

0

I was from posting this question working on my solution, until I got it follow the project link - Click codepen.io

Browser other questions tagged

You are not signed in. Login or sign up in order to post.