1

I am working on SEO on a multiregional site and we have a decent naming convention which is in English as the primary language of the site. The ideal would be to serve file names in regional languages but I also need to think about content editors and managers who might be searching for files and not speak the local language, even though we got a good folder structure but still. There is always ALT text that tells both Google and a user what is on the image. Besides, I've seen on multinational sites that they also don't use regional languages or even have a poor naming convention (not that I'm aiming for that) and still doing pretty well with SEO.

I heard there is a PHP function that can serve one image and change the file name based on a regional language, so I'm wondering how do you do that and does anyone have any source I can read about it?

In this case, do we still need to have translated text for the files to be able to serve them automatically or does it pull down the translation from google translate or how the translation works?

Rahul Devanavar
  • 3,917
  • 4
  • 32
  • 61
Vedra
  • 23
  • 2
  • I don't know why you got a downvote. I understood the question just fine and removed it. – Ususipse Nov 22 '19 at 09:18
  • What do you mean by "change the file name"? If you change it, how should it be served? – Nico Haase Nov 22 '19 at 13:50
  • Thought this function can translate the image file name when serving it to users in other regions without the need to upload the files with the local languages, am I right? – Vedra Nov 22 '19 at 14:49
  • Be careful with the phrase file name. In your case it seems you want to keep the same file and localize the alt text and description text so the actual file name will remain the same. – Ususipse Nov 22 '19 at 22:04

1 Answers1

0

Yes, that is the gettext function. It is called localization or l10n for short. You need to research PO MO files to get started.

Basically you set the locale, or allow the visitor to set the locale then the gettext function will match the string against the translations held in the MO file. There are PO file editors that will scan your files for gettext commands and list all the strings so you can easily populate the translations.

Ususipse
  • 303
  • 1
  • 9
  • Awesome, thanks! Ok so I would still need those image names translated which will be store in the mo folders, from which the function will then pull down the names to serve to the right locale? – Vedra Nov 22 '19 at 09:50
  • Also I wonder, if the files are not translated but we use this function, even though it will provide good user experience but will if also impact the SEO positively or Google won't notice it or does it still notices the code and can read the translation? – Vedra Nov 22 '19 at 09:55
  • Oh not the image name, or filename unless you want to serve different images to different locales. Typically you would localize the description and alt text. – Ususipse Nov 22 '19 at 09:55
  • Nah we would be using mostly same images on all regions and we have separate folders per region, because we will be translating alt text. However, we wanted to avoid translating image names to make it easier for content editors/managers to find files as many don't speak local languages. So you're saying that with this function we can serve english image files in local languages, which will translate both the file name and the alt text? Did understand it correctly? =) – Vedra Nov 22 '19 at 09:59
  • 1
    Close, the file name should stay the same or you would have multiple copies of the same image. If the alt text is 'apple' and you are locale ru_RU then the visitor's screen reader would read яблоко if your MO file is set up. – Ususipse Nov 22 '19 at 10:18