when the heck is 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never...

38
WHEN THE HECK IS 4/8/2016? AKA JUST ONE OF THE MANY THINGS THEY NEVER TOLD YOU ABOUT…

Upload: others

Post on 03-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

WHEN THE HECK IS 4/8/2016?

A K A J U S T O N E O F T H E M A N Y T H I N G S T H E Y N E V E R TO L D YO U A B O U T …

Page 2: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 3: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

WHO THE HECK AM I?

• Developer Advocate for IBM

• MobileFirst, Bluemix, Cordova/PhoneGap, and web stuff in general

• Blogging at raymondcamden.com

• Tweeting at @raymondcamden• Author of "Apache Cordova in Action" and "Client-Side

Data Storage"

Page 4: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 5: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 6: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 7: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

SLIGHTLY MORE COMPLICATED…

Page 8: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

TIL

• America is one country

• There are other countries

• They use the Internet too!

Page 9: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

BUT WAIT…

• They speak a different language (that's cool)

• They use a different unit of measurement (that's mostly cool too)

• "NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used English units of measurement while the agency's team used the more conventional metric system for a key spacecraft operation..." (oh crap)

• They write numbers differently (that's just insane)

Page 10: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

AN EXAMPLE…

1,000,000.99

1.000.000,99

1 000 000,99

Page 11: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

4/8/2016

Page 12: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

IS IT…

• April?

• August?

• It's my birthday – so you're both right!

Page 13: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

PROBLEM

• Numbers change

• Currencies change

• Dates change

Page 14: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

SOLUTION

• Pretend the rest of the world doesn't exist!

Page 15: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

REAL SOLUTION

• Detect the locale of the device

• Format numbers/dates accordingly

• Pro Tip: You can't just format American money into a Euro.– 1$ ≠ 1€

Page 16: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

GLOBALIZATION PLUGIN FTW

• https://www.npmjs.com/package/cordova-plugin-globalization

• cordova plugin add cordova-plugin-globalization• Supports numbers, currencies, and dates

• Supports getting information about locale/language

• Supports getting information about formats

• Even supports isDayLightSavingsTime – because that's still a thing apparently

Page 17: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

JUST ADD IT!

• Yes, you just add the plugin and your magically done!

Page 18: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

IDENTIFY CRAP TO UPDATE

• Check each view

• Look at the data

• Figure out what makes sense to localize

Page 19: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 20: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 21: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

http://www.raymondcamden.com/2015/10/14/adding-localization-to-your-ionic-application-with-ibm-bluemix/

Page 22: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

bankService.getAccountDetails().then(function(res) {$scope.bankAccount = res;

});

...

Total in account: ${{bankAccount.total}}Last Updated: {{bankAccount.lastUpd}}

Page 23: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

bankService.getAccountDetails().then(function(res) {

//$scope.bankAccount = res;navigator.globalization.numberToString(

res.total, function(number) {$scope.bankAccount.total = number.value;

},function() {}, {type:'currency'});

navigator.globalization.dateToString(new Date(res.lastUpd), function(d) {

$scope.bankAccount.lastUpd = date.value;}, function() {}, { options });

});

Page 24: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

OPTIONS

• For numbers:– decimal

– fraction

– currency (doesn't work in Browser)

• For dates:– formatLength: short, medium, long, and full

– "Apr 8, 2016 12:00 AM", "April 8, 2016 12:00 AM", "Fri, Apr 8, 2016 12:00 AM", "Friday, April 8, 2016 12:00 AM"

– selector: "date", "time", "date and time"

Page 25: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 26: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

Changed Region (Locale) to France but kept language to English

Page 27: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

Changed language to Frenchbut kept Region/Locale to US

Page 28: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

Changed both region +language to French

Page 29: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

WHAT TO DO?

• Currency seems inherently unsafe

• Given you use "X seashells" for country Y using the ** symbol – just format it as a number and use ** on display

Page 30: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

WE'RE DONE!

• Nothing else can go wrong

• It's all downhill from here

• Rainbows and kittens and cookies for everyone!

Page 31: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

WHAT ABOUT LOTS OF DATA?

Page 32: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

PROMISES!

• Just promise the hell out of that crap!

• JavaScript Promises

• http://www.raymondcamden.com/2012/11/15/Testing-Globalization-Support-in-PhoneGap-22/

Page 33: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

ALTERNATIVES – PART 1

• One of the many libraries out there

• Moment.js

• http://momentjs.com/docs/#/i18n/

Page 34: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

ALTERNATIVES – PART 2

• Intl

• ECMAScript Internationalization API

• window.numberFormatter.format(n);

• http://code.tutsplus.com/tutorials/working-with-intl--cms-21082

• OMG AWESOME NO PLUGIN NO LIBRARY PERFECT!!!!!!!!!!!!!!11!!!!

• Let's check CanIUse.com

Page 35: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 36: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…
Page 37: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…

BUT WAIT…

• I'm an American (sorry)

• I'm in America (not sorry – woot!)

• I'm looking at an event in France

• How should the date be formatted?

• Best for me – obviously? Right?

• Anything you do automatically – treat with caution

Page 38: WHEN THE HECK IS 4/8/2016? · when the heck is 4/8/2016? aka just one of the many things they never told you about…