Mobile app version of vmapp.org
Login or Join
Cugini213

: Multilingual Support on a PHP Website I have a very basic PHP website that is currently setup for two languages like so: lang.en.php - English strings lang.es.php - Espanol strings en/ - folder

@Cugini213

Posted in: #Language #Multilingual #Php #Url

I have a very basic PHP website that is currently setup for two languages like so:


lang.en.php - English strings
lang.es.php - Espanol strings
en/ - folder with PHP pages (PHP first processes the URL and loads the appropriate strings - in this case, lang.en.php); files are
EXACTLY the same as en/
es/ - folder with PHP pages (PHP first processes the URL and loads the appropriate strings - in this case, lang.es.php); files are
EXACTLY the same as es/
index.php - redirects the user to the appropriate sub-directory based on the user's browser language


This seems to work fine for both SEO and easy management, except for the file duplication in the en/ and es/ folders. If I ever want to update/add a page, I have to upload the same file to both en/ and es/. Is there a way to have the en/ and es/ folders pull the same files from say, a common/ folder? I would like to keep the en/ and es/ directories because it's user friendly and, from my understanding, good for SEO.

Any help would be much appreciated!

EDIT: I've considered using a GET variable for the language (ie. ?lang=en) which would solve my issue of duplication and allow me to replace the directories en/ and es/ with a common directory for all languages in which each page's language is determined by the lang variable. However, would this be bad for SEO?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini213

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

Instead to redirect in the index.php file to the appropiate folder, do this:


Load appropiate language file based on the user's browser language (a simple "require").
Instead of redirect the user to the folder, load ("require") from the 'common' folder the file that user asked for.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme