7

I have one site with two languages: English and Spanish for example. What would be the proper convention to name image files?

From my point of view it would be stupid to duplicate image and then name it according to on which site it will be uploaded. It would be waste of resources IMO and unnecessary job to do.

What do you think about this one?

Simon Hayter
  • 33,097
  • 7
  • 60
  • 119
RhymeGuy
  • 439
  • 3
  • 12

4 Answers4

3

If duplicating the image really is unnecessary then you could still perhaps have the best of both worlds... only store the image once, but have it referenced by different filenames, for the different languages - using mod_rewrite (Apache) and an internal rewrite.

Based on unor's example:

  • example.net/img/en/house.png
  • example.net/img/es/casa.png

These would be internally rewritten to send a request to your server-side script:

  • imgScript.php?file=en/house.png
  • imgScript.php?file=es/casa.png

Your script knows to serve the same image for both requested files, perhaps with a simple lookup associative array:

array (
  'en/house.png' => 'real/path/to/my-house-pic.png',
  'es/casa.png' => 'real/path/to/my-house-pic.png',
  // etc.
);

This method allows you to serve different images for certain files if you wished.

MrWhite
  • 43,224
  • 4
  • 50
  • 90
2

Two solutions which don't require filename changing but give a different file path:

  1. Create different domains which forward to the same directory, where the site then detects language and servers correct paths/site content. e.g. website.es would pull content from website.com so website.com/picture.jpg becomes website.es/picture.jpg

  2. Similarly use subdomains on the 'main' (for me this is the first site and usually language of site owner/main admin) site such as es.website.com and dk.website.com (this is cheaper too :)) and use the same approach as above pulling site from one directory and getting language specific URLs like es.website.com/picture.jpg

What both of these solutions don't offer is a meaningful file name like previous answerer noted table.jpg or mensa.jpg

However, using meta info like alt and title tags, not to mention surrounding content and language declaration of the page the file is on will compensate. Also with both of the above solutions you can set the geolocation of the site url (and content) in Google Webmaster Tools.

This sounds like a lot of work but if you use a popular CMS there are plugins for it.

dan
  • 15,153
  • 11
  • 46
  • 52
S..
  • 415
  • 2
  • 11
1

If the concern is SEO, according to Google, image name and path is a very small ranking factor, and they would see all other images as duplicate and hold only one url. Then, it is practically better to use only one image name and path in main language for all the language page versions.

seeker
  • 11
  • 2
1

Well, there are 4 ways if you don't want to duplicate your images:

  • in English (house.png)
  • in Spanish (casa.png)
  • in English and Spanish (house_casa.png or casa_house.png)
  • no linguistic content: (alpha-)numerical ID, date (2012-09-25.png, 123.png, …)

But I would duplicate them. Images are content like text, PDF, videos, audio, …, too. So in general you probably have (or need) an infrastructure that allows you to provide translated media files. Of course there are media files that don't need any translation (silent films, photographs without textual information etc.), but I like to think of them as exceptions (doesn't matter if they really are).

So I'd go with (even if the images would be the same):

  • example.net/en/house.png
  • example.net/es/casa.png
unor
  • 21,919
  • 3
  • 47
  • 121