[Quest 6] Someone in the UK (or anywhere outside of the US), test this, please

Hello.

https://textadventures.co.uk/games/view/xvipcdcp_ewr8xcinzxbvg/color-or-colour

This is just a very simple test using QuestJS v0.8.


Examine the object named "tester".

It will say: "Does this say 'color' or 'colour': ??????"

Hopefully, in the US, the ????? are "color", and they are "colour" anywhere besides the US.


createItem("tester", TAKEABLE(), {
  loc: "lounge",
  examine: `Does this say 'color' or 'colour': ${navigator.language === 'en-US' || navigator.userLanguage === 'en-US' ? 'color' : 'colour'}`
})

I guess Australia is outside of the US. (although sometimes I wonder if we are the 51st state)
When I ran it it said it was color - the US spelling.
Where do you get navigator.language and navigator.userLanguage ?

By default, my Windows display is English(United States) and all the others (Apps & websites, Regional format, Keyboard, Speech) are set to English(Australia). I think these are all obtained from the Region settings.


Says "colour" for me in the UK.


@R2T1 said:

I guess Australia is outside of the US. (although sometimes I wonder if we are the 51st state)

Ha!

That's a good idea!

We could use your resources!


@R2T1 said:

Where do you get navigator.language and navigator.userLanguage ?

JS navigator object

navigator.language

navigator.userLanguage is what Opera uses (I think).


@R2T1 said:

When I ran it it said it was color - the US spelling.

By default, my Windows display is English(United States) and all the others (Apps & websites, Regional format, Keyboard, Speech) are set to English(Australia). I think these are all obtained from the Region settings.

Hrmm... Someone on StackExchange said:

My testing suggests that while this works in IE and Firefox, it does not work in Chrome. Chrome's navigator.language is always the language configuration of the installation of windows, rather than the language configuration of the browser.

Are you using Chrome, R2T1?


I'm going to try navigator.languages[0] || navigator.language.

That appears to be the "new way" that checks the browser user preferences.

It looks like navigator.userLanguage might be outdated, anyway. When I tried to find a link for it, I couldn't really find one. I also just realized the StackExchange post I got it from is 10 years old. (Huh-huh-huh.)


@The Pixie said:

Says "colour" for me in the UK.

Like all things cross-browser, I expected it to work about half the time. :)

Which browser did you test it in, if you don't mind me asking?


PS

Thanks to everyone for testing this out!

If it ends up working, it sounds like a good way to have the game speak American (i.e., 'center', 'color', feet, inches, etc) when applicable. Most of us don't know what a meter is, and, even if we knew the formula to convert it to our system, most of us either don't know how to or simply don't like to fool with math. (We're keeping it real!)


I uploaded v0.2.

Now, the code is:

  examine: `Does this say 'color' or 'colour': ${(navigator.languages && navigator.languages[0] === 'en-US') || navigator.language === 'en-US' ? 'color' : 'colour'}`


That might work correctly in Australia. . .


I'm confused. My navigator.language is apparently en-UK. Which is weird, because there's no such locale. (My LANGUAGE environment variable is set to en_GB.utf8 which is what I expected)


I'm confused.

Well, if it's confusing you, I don't have much hope of understanding it. . .

What is your navigator.languages[0]?


Has the game been updated? When I click the link in the OP I still get color.

> x tester

Does this say 'color' or 'colour': color

I was using FireFox for testing both times.
... A bit more testing...
Firefox - color
Brave - color
Opera - color
Chrome - colour
Edge - colour
Vivaldi - colour

That's all the browsers I have installed. Hopefully it may give you a better handle on it.


Has the game been updated? When I click the link in the OP I still get color.

Yep. It just didn't fix it.


That's all the browsers I have installed. Hopefully it may give you a better handle on it.

Thanks for that!

I see it only works half the time. Sounds like it fails the test, unfortunately.


For Chrome and Edge it says "colour", and for Firefox "color". Same as R2T1.


Well, if it's confusing you, I don't have much hope of understanding it. . .

What is your navigator.languages[0]?

navigator.languages is ['en-GB', 'en-AU', 'de', 'jp', 'en']… which isn't what I expected, but at least it doesn't contain codes that don't exist.

I'm assuming that de is included because I sometimes use a computer that's physically located there; and jp because I have my IME setup so that I can type Japanese.


Well, if it actually worked across all the browsers (ha!), it would have been a pretty good idea.

In retrospect, I can't believe I didn't realize there would be compatibility issues from the beginning.

Much thanks to everyone for testing it out! :o)


It is flagged as experimental here:
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages
https://caniuse.com/?search=Navigator.languages

Though Firefox and Chrome have supportef it since 2014


uhm...
I live in Malaysia - waaay too far away for you to fly to me so don't even think about it - and I use "color".
Might just be my biased opinion, but I don't think Malaysia uses "colour".
Just saying.


I realise now that this will also default to UK spelling if the browser's default language is non-english. Might be better to loop over all the supported languages until you get to one you know. So for 'color', you'd have something like:

regionalWords = {
  color: {
    'en-US': 'color',
    'en-MY': 'color',
    'en': 'colour'
  }
}

Although that makes 110n quite a bit more complex (even if you don't adapt for different meanings of words).


I live in Malaysia - waaay too far away for you to fly to me so don't even think about it - and I use "color".

This made me laugh. I needed that today.

:o)


Might just be my biased opinion, but I don't think Malaysia uses "colour".

Duly noted.

I thank you kindly for the feedback.


I realise now that this will also default to UK spelling if the browser's default language is non-english.

Meh. It seemed like a good, easy way to handle things, but I should have known better than to believe that.

Now, I'm thinking the best way would be to ask which version of English the player prefers when the game begins.


Log in to post a reply.

Support

Forums