Jump to content

Include() - Where Are The Limits?


djp1988
 Share

Recommended Posts

Hi everyone !I am developing a multilingual websiteHaving done an english and french site before which was VERY messy, actually having a en/ and a fr/ directory with separate files for the same info in different language, I have this time a much better understanding of what is possible, anyway, I was thinking for information such as navigation html and footer information, that I'd just store this information in a table on the database and go and get it according to what language the php variable was set in, but then I thought, this could be a very big bomb waiting to explode, far too many queries for the same info, so I have gone one step back and decided to use a "switch" to determine what file to include, for example I have a "english-menu.html" "french-menu.html" etc...But I don't want these separate files to be accessed in the url bar of a browser, can I somehow make these files only accessible through the include() function ? Or do I have to do something server side? Also, about the include() function, I tried giving it a variable include($file);And it didn't want to use it, why ?

Link to comment
Share on other sites

Here is what I would do, have the page include either French, or English files depending on what the value of a cookie said. so,include("languages/{$_COOKIE['lang']}/menu.html");//Example: languages/french/menu.htmlSo if they spoke French, you set a cookie to 'french' so it would get all of the French files.and you said include($file)... what was the value of $file? it should have returned an error of some sort too.

Link to comment
Share on other sites

Very interesting concept, I am working with that now as you suggested, but how are multiple language sites built? is this a common way to toggle between languages? What other ways are possible, my first attempt as i said was a fully written page for english and another for other languages, a nightmare to keep up to date, otherwise I thought about making a table with the key words used for navigation and other larger chunks of text such as welcome paragraph or chunks of html used for the footer, and query them according to the language setting, but this of course is a HUGE strain on the db, in my opinion. Please share your ideas on how you would run a multi-language site and how you think other sites do this...

Link to comment
Share on other sites

That is pretty much exactly how a multi-language site could be done.Download a copy of sNews CMS to get an idea how they do it. Pretty much that same way. The hard part is defining all the core components and remembering to use them as you echo data out. Well, it gets to be a remembered thing, but it does bulk up the code, of course.One other difficulty is that the the page components could have one language and the data for the site could be in another. For instance, I speak/read/write English and visit a French site, set the cookie to English, and all the link buttons change to English but all of the page data is in French as written by the Author. In that case, you would need an English Translation available for the English Cookie Users.Have you considered that?*edit*fix typo*edit-edit*fix a typo on the typo fix :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...