You Are Here:

Community: Wiki

This page was last modified on 22 September 2009, at 06:44.

Using Locale, date & time Flash Lite

From Forum Nokia Wiki

Reviewer Approved   
== Using locale data in Flash Lite ==

Contents

The i18N trap

Internationalisation (or internationalization in some places...), also known with the abbreviation i18N (18 letters between the i and n ;o) Is a crucial part in user-friendliness. And even if you are developing only in English, you should keep in mind, that at least the date and time formats should be shown to the user the way they are familiar with and understand.

Why? You will ask... Here's an example: You have just created a Flash Lite movie, that advertises a competition that has an ending date. It's now the 7th of March and you have stated, that your competition finishes 5/3/2008. So there's almost two months time, right? Not exactly. Even though for US and other American users see that date as "3rd of th May, most Europeans would read it as 5th of March and the deadline already missed. For someone in Japan or Sweden, who both use a date format similar to 2007/5/3, this would be even more confusing. They first need to find out the author's nationality and then figure out which one of the two possible dates it might be...


You can even crank the confusion up a notch and use the two digit format for the year and beginning zeroes for month and date and end up with a date like 07/03/08. Which one is that!

  1. The 7th of May 2008
  2. The 3rd of July 2008
  3. The 3rd of August 2007

Tricky eh...

Locale is your friend

The thing to do here, is to utilize the fact, that Flash Lite is aware of the locale


of the device it's on and you can simply ask for the appropriate date format to be displayed.

The following code simply reads the current date and assigns it as avalue to a string variable called nowDate.


status = fscommand2("GetLocaleLongDate", "nowDate");



If you need to play around with the time, language or weekday, see the following example. Keep in mind, that the GetDateWeekday fscommand returns a number, that you need to translate into a weekday name in your code.



function getLocaleData(){
status = fscommand2("GetLocaleLongDate", "nowDate");
numDay = fscommand2("GetDateWeekday");
status = fscommand2("GetLocaleTime", "nowTime");
status = fscommand2("GetLanguage", "isoLang");
 
switch(numDay){
case 0:
weekDay = "Sunday";
break;
case 1:
weekDay = "Monday";
break;
case 2:
weekDay = "Tuesday";
break;
case 3:
weekDay = "Wednesday";
break;
case 4:
weekDay = "Thursday";
break;
case 5:
weekDay = "Friday";
break;
case 6:
weekDay = "Saturday";
break;
}
return = "Today is:" +newline+ weekDay +newline + nowDate +newline + nowTime + newline+ newline +"Locale:" +newline +isoLang;
}

Time is of the essence too

When you have figured out, how to show the date, you have to keep in mind, that the time of the day needs to be localised too. The format used to display the time does not only differ in the usage of 12 or 24 hour clock, but also the separators between the numbers are different.

Your user will recognise the time if you use the following fscommand. The function below assigns the system time of the handset to a string variable LocalTime.

status = fscommand2("GetLocaleTime", "LocalTime");

Please comment

Please use the comment tab to give feedback on this article

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fmakeE5faE5fsignalE5findicatorX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZflashQ qfnZtopicQUqfnTopicZflashE5fliteQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ