My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.

Tuesday, October 06, 2015

Object.assign Side Effects and How To Copy

In How To Copy Objects post I'll explain the difference between various native ways to copy own keys and properties, describing also the fact that Object.assign is full of surprises and side effects.

As example, assigning to an object something like {get next() {return ++this.i}, i:0} instead of {i:0, get next() {return ++this.i}} will result in different values copied over: next === 1 and i === 1 in the first case, next === 1 and i === 0 in the second one.

Friday, October 02, 2015

On Ignored Users Spoken Language

I think I've talked already few times about this problems but I don't see anything happening ... actually, it's getting worst and worst.

Who Is Directly Affected And Is Wasting Money

  • Companies paying for Online Advertisement
  • Companies selling online
  • Companies providing online services

Who Is Responsible

  • every service that is addressing users through their current IP address, without asking permission, and assuming if you travel to any country in this world you automatically speak that country language
  • every service that completely ignores Accept-Language on the server side, and navigator.language on the client side
This is an extract from the Accept-Language used for locale setting post directly from W3C website:
For a first contact, using the Accept-Language value to infer regional settings may be a good starting point, but be sure to allow them to change the language as needed and specify their cultural settings more exactly if necessary. Store the results in a database or a cookie for later visits.
By the way
Using the Accept-Language header is also a good starting point for determining the language of the user, rather than the locale ...
Accordingly, instead using users IP location to define their language, I'd rather prefer them to use my daily language of choice, which comes most likely from the fact that my entire Operating System speaks English, as example, so PLEASE, give me English content whenever I am!

It feels so straightforward simple thing, right? Wondering who is doing it right?

Nobody Is Doing It Right

I am in Germany these days, and suddenly I don't understand anything. I cannot even be "victim" of Ads, I'm rather disturbed by them.


Before even asking to use my detailed location provided through the browser, if I type in the URL bar I'm redirected to Why does that happen? Simple, they know by my IP I am in Germany ^_^.
If I choose the English language and I search for O2 DSL, imagining I'd like to sign for a contract, or need some help, this is the result:

...which is completely useless. Probably most of the resulting sites also have an English page equivalent, and if I go there probably Chromium will ask me to translate the language ... but how come I don't have translated previews?
How come there are specifications about this problem but nobody is using meta information that exposes all supported languages, so that eventually a search result could tell me upfront if the target site supports English, as example, and I can eventually go and try to read it, instead of trusting just an automatic translation that we all know is rarely that reliable?

It's not all that bad though, things are improving at least on Google side. While in Germany, I've managed to watch an English movie through Google Play and I'm actually happy because last time I've tried, it did accept my payment but it didn't let me watch it because not allowed in that location.
Still room for improvement all over but progress too!


While Google might be an online service in the wild, Facebook actually perfectly knows which language I speak: is the one I use to use Facebook, no crystal ball involved. Regardless, somebody is wasting money trying to target me and I'v e no idea what are trying to sell.


I've always said that one of the best things Twitter does about advertising is targeting properly so that it's the only service where I actually want to click on Ads, and not just by accident, because these are always relevant and also it's not immediately obvious that these are ads, but I'm usually interested anyway ... so kudos that!
But now that I am in Germany, I've realized there's quite a lot of advertisement in my stream, and I cannot even understand it anymore. Do people pay by impressions? Well, all of mine during these days shouldn't probably count as one.

Does Twitter know I speak English? Hell Yes, it's explicit on my settings! Accordingly, if they even offer a top right View translation info, why on bloody Earth they don't show me the translated one directly?
Moreover, I've clicked just to see if that ad, whatever it is, could have been something interesting, something I could have changed language once in their site, since there was even a translation option offered to me ... guess what? NO, it's a company that does something I've no idea and never will have interest to know because I'm frustrated about this ridiculous situation and I don't care anymore what they do!

Overall On The Web

Even this blog keeps redirecting me to its .de counterpart, and the automatically provided EU Cookies law yet is still in English. Some consistency on this is basically impossible to find on the Web, and every website that thinks is doing a smart thing with this pointless IP-to-language assumption, inevitably fails at providing essential UX expectations.

Dumb Languages Options

Another common approach is to offer a list of alternative languages or countries ... drum rolls ... in the current language: this should STOP!
If I am looking for a way to change language, it means at least two things:
  1. I don't understand the current one
  2. I obviously understand the one I am looking for ... but I NEED TO FIND IT!
If I am a German person and I don't know English, but I am in UK so the site will be served in English, I need to be able to find Deutsch, not German .... Deutsch!
On the other hand, if I speak English, but I am in Germany, and I am making an online payment via PayPal, and they are "smart-ass" like everyone else so they serve me a payment form in German, the moment I look for an alternative country to bill me, since there is no direct change language option, I have probably no idea that I should look for Vereinigtes K├Ânigreich instead of United Kingdom.
What is the point of showing me countries for my billing address in a language I don't understand?
I have managed to pay via something like Hanoi Tower mechanism: find another country I could recognize, switch to that one, then find from that country language something I could recognize as United Kingdom: and this is plain dumb!
How is that possible that services like PayPal haven't figured this out yet?

How It Should Be

I am not sure if this problem is because of lazy developers, but I am pretty sure every service would like to grant best UX for their users, and possibly best onboarding, or retaining, or even advertising experience.
However, I wonder why there's basically no common sense, even after official W3C recommendations, about this matter.
Following a list of good ways to address this problem that is of course open for discussions, but I hope it will be addressed as a little reference to stick with.
  • use Accept-Language and/or navigator.langauge to understand the default language expectations from the user, in case your service supports multiple languages. Offer the service in such language first.
  • The first "change language" option should be the one spoken in the current country, if different from the one chosen in the previous point. If these are the same it could be alphabetically or by region or ... it probably doesn't matter much.
  • Always offer alternative countries and languages in respective countries spoken language. Switzerland, as example, is an exception but everyone in there would understand Switzerland. They are smart, they speak about 4 languages if not 5: they are not as lazy as the rest of the world.
  • Use a standard way to instantly let the user, or the crawler, know it is possible to change language because supported, not because Google can translate that for us. This is a very different situation: any site could be translated but maybe, after that, nothing else could be done (buy, order, even pay if the check is for local Bank fields only like the sort code in UK)
  • use the IP location combined with user explicit language of choice, and never assume the spoken language by country!
The last point is again a recommendation from W3C based on Content-Language I've rarely seen applied out there.

As Summary

I whish you to travel a lot in countries that speaks a language you don't understand ... I really do, it's like a curse these days!
The Web supposed to drop barriers, here we have a whole new level of stupid choices through a practice considered smart: using the IP address to assume tons of, most of the time wrong, users choices!
We can do much better, and it's for our own sake ... shall we try harder, please?
Thanks for reading.