Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Variable for languages? Rate Topic   - - - - -

 
  • scooterlord
  • Advanced Member
  • Members
  • Join Date: 29-Jun 13
  • 111 posts

Posted 24 August 2013 - 02:47 PM #1

Hello,

does anyone in here know what variable is used to detect a language? I am talking about variable for language and NOT using language variables.

For example:

if ($language=English) {
do.this();
}

?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11203 posts

Posted 24 August 2013 - 07:17 PM #2

It is set in the cart during initialization.
It is a constant called CART_LANGUAGE and in the admin area, it is either CART_LANGUAGE or DESCR_SL when editing things in other languages.

At init time, first thing is it's set to whatever the default language is for your cart. Usually 'en' (V4) or 'EN' (earlier than V4).

Then it looks for an SL parameter and uses the language specified with that. I.e. yourstore.com?SL=fr.

If no SL, then it looks in the user's session and uses a language variable that might be set there.

If all of that still doesn't result in any language change, then it looks at what the browser has requested (if anything).

So what you really want is:
if( CART_LANGUAGE == 'en' )
  do_this();
}

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • scooterlord
  • Advanced Member
  • Members
  • Join Date: 29-Jun 13
  • 111 posts

Posted 25 August 2013 - 12:21 AM #3

Excellent! Thanks for the help! Will try it tomorrow! :)

 
  • scooterlord
  • Advanced Member
  • Members
  • Join Date: 29-Jun 13
  • 111 posts

Posted 25 August 2013 - 03:56 PM #4

uhm, tbirnseth, what syntax should I use exactly in cscart? I tried using it inside <?php ?> but it's not working..?

edit: just some extra info, I am trying to use this code inside the .tpl files.

I also tried the smarty way:

{if CART_LANGUAGE == 'en' }

hello

{/if}

but still no luck.

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1243 posts

Posted 25 August 2013 - 04:14 PM #5

Please try
{if $smarty.const.CART_LANGUAGE == 'en'}
hello
{/if}

---
Valentin
part of hungryweb.net

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11203 posts

Posted 25 August 2013 - 07:36 PM #6

@val - The example he gave was php code which is what I gave back to him and the tags he used indicate also that he's using php versus trying this inside the template.

If the OP could specify "didn't work" then it might help. I gave him a V4 use of language codes and if he's not running V4 then all he probably needs to do is change 'en' to 'EN'.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • scooterlord
  • Advanced Member
  • Members
  • Join Date: 29-Jun 13
  • 111 posts

Posted 25 August 2013 - 08:12 PM #7

tbirnseth,

sorry if I caused any inconvenience, I didn't mean to.

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1243 posts

Posted 25 August 2013 - 08:14 PM #8

or

{if $smarty.const.CART_LANGUAGE|lower == 'en'}

hello

{/if}

for v3 or v4 ;), i really don't know the reason why they need change into v4 from uppercase to lower case this variable