Jump to content

Switch from one language to another


kalyncomputers

Recommended Posts

Hi,

 

I have a site I am doing in French and English using the latest build of CC.

I would like a way to call either language from an html page, i.e. I can easily call the shop from the index.html page but I cannot work out how to call a specific language from that page.

Ideas anyone?

Just been testing the site and found something strange. The shop comes up in English and I can switch to French by clicking on flag but when it's in French, I can't switch back to English. I will try an install on another domain to see if the same thing happens.

Thanks

Tim

Edited by kalyncomputers
Link to comment
Share on other sites

Hi,

Thanks for the help.

Well it works, sort of! I can certainly get it to display the French version but still cannot switch back to English, even using ?set_language=en-US. Very strange as I am sure it was working last weekend.

I'll try updating to 6.1.7 so that everything is bang up to date.

Hi,

 

Upgraded to 6.1.7 OK but still have the same problem.

I'll try do a completely clean install and see what happens.

 

Tim

Link to comment
Share on other sites

  • 9 months later...

Let's try this. In /classes/tax.class.php:

Near line 58, find:

			httpredir(currentPage(array('set_currency')));
		}

Change to:

			httpredir(currentPage(array('set_currency')));
		} else if(!$GLOBALS['session']->has('currency', 'client')) { switch ($GLOBALS['language']->getLanguage()) { case 'en-GB':$GLOBALS['session']->set('currency', 'GBP', 'client');break; default:$GLOBALS['session']->set('currency', 'EUR', 'client');break; } }

This adds a test where, if the visitor has not previously selected a currency, then set a currency based on the language being used:
en-GB uses GBP, otherwise use EUR

 

Link to comment
Share on other sites

Hi bsmither,

thank you for your help.

Only, it has only helped partly.

It does now show euros on the Dutch part of CC, but when I access CC from the English part of the site, although the URL is set as https://www.m6vmo.tk/cube/ as opposed to ......./index.php?set_language=nl-NL, the English part now also opens in Dutch and in Euros.

When I access the site on my mobile, the same thing, except that both languages are in £.

Probably a small oversight, I guess.

Cheers.

Link to comment
Share on other sites

It is probably because once the SESSION knows what currency the customer wants or has been given, that will be the currency used regardless if the visitor then changes the language to show.

The decision to guess at which currency, based on the language being used, to show is predicated on CubeCart not knowing what currency to use, and this works if the visitor does NOT have a cookie.

In your store's settings, which language and currency is set as default?

Link to comment
Share on other sites

On my website https://www.m6vmo.tk one part is in English and one part in Dutch.

The URL to the shop on the English part is  https://www.m6vmo.tk/cube/ and on the Dutch part it is https://www.m6vmo.tk/cube/index.php?set_language=nl-NL

On the index page of the site there is a button to choose the language you want to see the main site in/

In case you want to visit the site, it is still under construction, but the parts I mentioned are all working.

 

 

Link to comment
Share on other sites

Just to get something clear in my mind, these two web addresses are actually the on and same store, but the store is simply using different language packs. The ?set_language=nl-NL is no different than ?set_language=en-GB other than the instruction of what to set the language to be shown.

Regarding the code changes above, what I am trying to avoid is to absolutely lock a currency to a language.

So, when the visitor wants to view nl-NL, but the currency has already been chosen to be GBP, I avoid forcing the visitor to see EUR.

Once CubeCart has been told to use a particular language, either through making that choice from the choosers or by default, CubeCart remembers that.

Link to comment
Share on other sites

We strongly advise that only one CubeCart instance communicate with its database. Maintaining two installations - wanting to keep inventory, customers, and documents synced would be bothersome.

Let's review what you want --

When a visitor who has never been to your store arrives for the first time, what do you want to show with respect to language and currency?

Do you want to lock that visitor to seeing only that initial determined setting?

If not, when the visitor chooses one of the settings, what do you want to happen to the other setting?

Link to comment
Share on other sites

Well, quite simply, since the articles in the shop will be the same for whatever language, I just want the visitor to see the shop in his/her own language, ie. the language of the part (English or Dutch) of the website they selected the shop page from.

"Locking" is, of course, a big word, but there is not really much point in people being able to change to the other language as, like I said, the contents of the shop will be the same, and also, not many Brits are likely to understand Dutch, are they?

So, basically, it does not matter much what happens to the other settings, as long as the visitor can see and use the shop in his/her own language and currency upon arrival (If they can change those, fine, if not, fine too).

Link to comment
Share on other sites

There is also some code (somewhat difficult to actually test) that will determine the language that is "acceptable" according to a header that the web browser includes in the page request.

So, if that header has: "Accept-Language: nl-NL", then CubeCart will switch to showing it.*

The code posted above will determine that the customer's selected language is not en-GB, and will then switch to showing EUR.*

* The switch will happen unless either of the following happens:
-- the visitor uses the language or currency choosers to override any pre-determined or default setting
-- the visitor has returned and is still using the same cookie

"... to see the shop in his/her own language, ie. the language ... they selected the shop page from."

So the visitor made a language/currency selection from some place prior to arriving at your store?

Link to comment
Share on other sites

Yes, as I mentioned before, the main site, https://www.m6vmo.tk has two buttons on the homepage (index.html), these buttons are there to choose what language to surf the site in (English or Dutch).

When you select the link to the shop on the respective chosen page, the intention is to get to the shop in the chosen language of the main page.

 

Link to comment
Share on other sites

I think I see what you want. If so, let's try this:

Restore the code in the Tax class back to its original version.

Then, on the welcomeeng.html page, for the 'Store' link, have:
/cube/index.php?set_language=en-GB&set_currency=GBP

On the welkomnl.html page, for the 'Te koop' link, have:
/cube/index.php?set_language=nl-NL&set_currency=EUR

This initially sets both language and the matching currency, and still lets the visitor to change either at will.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...