Detect Browser language list...

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the Construct Starter Kit Collection and the Student Workbook from the Workshop.
  • Hello folks - I'm using the Browser object to detect what language the user's phone is so I can serve them translated graphics.

    Currently I've got:

    SYSTEM > compare two values > Browser.Language = VALUE TWO

    It's this VALUE TWO that I'm having an issue with. I'm guessing there is a list of Browser language identifiers somewhere.

    Does anyone have a list or can anyone point me in the right direction?

    Thanks all :)

    Tagged:

  • This is what I found in google:

    metamodpro.com/browser-language-codes

    Also, you only need the first two letters of the language code. For example:

    left(Browser.Language,2) = "fr"

  • Smashing thanks. I'm guessing i can use the full character string though if I need to, as multiple countries use the same two letters as their first letters, eg:

    en: English

    en-au: English (Australia)

    en-bz: English (Belize)

    en-ca: English (Canada)

  • OK - I seem to be having a bit of a problem with this. I've got the events working, however the codes seem to be not selecting properly. I've currently got:

    System > On Start of layout >

    System > Browser.Language = "en" > System Create object "England" on layer TITLE at (240,160)

    System > Browser.Language = "en-ca" > System Create object "Canada" on layer TITLE at (240,160)

    However when the iPhone language is set to UK and I expect it to display the "en" "England" title nothing displays.

    But when I set the iPhone language to Canada I expect it to display the "en-ca" "Canada" title, but it displays the "England" title instead.

    In an answer above dop2000 says I only need the first two letters of the language code, but I really want it to check all 4 (or 5 if you count the -) if available. Any ideas on how to do this?

    Thanks all :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can compare in a parent event if the first two letters are "en". And then in a sub-event check for a more specific locale - if "en-ca", then Canada, everything else is England.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)