: How to name image files in multi language site? 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
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?
More posts by @Carla537
3 Comments
Sorted by latest first Latest Oldest Best
Two solutions which don't require filename changing but give a different file path:
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
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.
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.
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
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.