PDA

View Full Version : Need code, auto change site's language


Nikola Bosnjak
10-22-2010, 05:21 AM
I'm using vB 4.0.5 CMS, and site is in 2 languages. I have articles in Croatian and English. I would like vBulletin change the system language depending on what content a user is reading. So, when a user is reading our company info in english, I want "read more..." link in english, but when local user is reading a company info in croatian, I need the same link "read more..." to be in croatian.

So far, I have idea to stick each language to a CMS layout, something like "if layout=1 then langid=1 else langid=2...) but I'm not programmer. I don't know how to do this. Is it possible?

Could I do this with sections, maybe? Becouse all my english content belong to one section, and croatian to another. If I could define default language for a section (I know it's impossible without programming), than my problem is solved.

lemonadesoda
10-22-2010, 05:39 AM
Hello Nikola, I'm not sure if that really is a good idea. Example: EN speaking User cannot read CR has EN language option in their User Settings. Goes to CR language page and loses EN language for orientation and gets lost. Conversely, CR speaking User cannot read EN has CR language options in their User Settings. Lands on an EN page and loses CR language for orientation and gets lost.

Your idea only works for bilingual Users and not monolingual Users. But bilingual Users can do fine in either language so it really isnt a problem.

Oh wait, your idea is helpful for Guests who have no language settings. That means your condition should include "if guest...". Alternatively, make a flag icon on the CMS template to switch languages easily.

Nikola Bosnjak
10-22-2010, 08:19 AM
Oh wait, your idea is helpful for Guests who have no language settings. That means your condition should include "if guest...". Alternatively, make a flag icon on the CMS template to switch languages easily.

I must agree that it is not mandatory for every-day users, but site is made some days ago and all users are new. I made two flags above title image that links to ".../content.php?49&langid=1" and ".../content.php?langid=2". This is almost enough, klick on english flag changes the content that is in use and also changes the language to english. The problem is that there is a lot of ways how each user can see CR content and EN links, and this looks silly. For example, klick back on browser and refresh a page, or if a user comes via google... Let's say you enter some EN keywords in google and come to our site. It is obvious wou want to use EN on our site.

Nikola Bosnjak
10-28-2010, 06:11 AM
Here is our site:

www.hora-elektronik.hr

As you see, it has 2 flags in the header, each of them is changing both language and section. So, how to make that better? How would a code that changes language depending on layout look like?