Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 17:54, 20 May 2008.

Using Locale, date & time Flash Lite

From Forum Nokia Wiki

Contents

Using locale data in Flash Lite

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 Discussions
Thread Thread Starter Forum Replies Last Post
Launching a Python script (with arguments) from Flash? bouvin Python 14 2006-08-22 18:33
webkit library and flash lite plugin mfarooqkhan78 Symbian Networking & Messaging 3 2006-11-21 20:35
Virtual World API with Flash Lite joaach Flash Lite on Nokia Devices 0 2008-03-09 18:35
Flash Lite Application Charset Problem D.Luciani Carbide.c++ and CodeWarrior Tools 3 2007-03-07 14:30
Browsing Question midgar General Browsing 5 2006-09-22 11:08
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZflashE5fliteQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX