Wednesday, May 15, 2019

International functionality Part 2: Local conventions

In my last post I discussed how MyFlightbook handles different languages.  In this one, I will discuss how MyFlightbook handles regional differences.

Language and Region are independent variables.  E.g., English is spoken in both the US and the UK, but we express our dates differently.  I am writing this on May 15, 2019.  In the US, the short form of that date would be written 5/15/2019 (i.e., month/day/year), but in the UK, it would be 15/5/2019 (day/month/year).

Besides dates, there are several other conventions that vary based on locale:
  • Times.  E.g., by default is 4:15pm expressed  as "4:15 PM" or as "16:15"?
  • Decimal points and thousands separators.  E.g., one-thousand two-hundred fifty-two and a half would be "1,252.5" in the US or "1 252,5" in France.
  • List separators: typically a comma or a semicolon.  This is particularly important for CSV
  • Currency symbols.  Obviously, the US uses $, but Europe uses €
All modern operating systems provide services that software like MyFlightbook can use that makes all of this automatic and transparent.  MyFlightbook uses those services, so all conventions should be followed appropriately.

The trick is to ensure that MyFlightbook knows which region should be used.

For the apps on iOS or Android, you can set your device's region by going into the device's settings app.  There's a language and region area where you can set both the preferred language (as discussed in the last post, the iOS and Android apps are translated into French as well as English) and your preferred region.  Most people do not need to do anything here because their device comes pre-configured for their language and region.

The website gets slightly more complicated because it is one instance of the software that is running on a machine in the US (in the cloud somewhere; I actually have no idea where), so it is using US conventions, but it needs to service people from all over the world.  How to solve this?

Whenever your browser requests a page, it sends a list of language-region codes along with the request.  A language region code looks like "en-us": the "en" part means it is requesting English language, and the "us" part means it wants to use US conventions.

The list of these codes is in priority order.  So a request might include the following list: "en-us", "en-gb", "fr-ca", "fr-fr".  This tells the server that English is preferred, then French.  And that the preferred regions are US if possible, then UK ("gb" = "Great Britain"), followed by Canada, then France.

Note that this is sent by the browser, so if you are using a Windows or Mac OS with, say, French Canadian conventions, but your browser is set up for English/US, then you will get English.  The MyFlightbook server can't see your OS's settings, it can only see what the browser sends.

This can be set in various ways, depending on the browser.  In Chrome, you'd go to settings (using the menu or the URL chrome://settings/), then go to advanced, and you can specify language/region there:

In Firefox, you'd go to Options (or about:preferences) and find Languages from there:



In my next post, I'll talk about regional functionality.

No comments:

Post a Comment