The Windward Studio

Windward Blog Home

Report Locale Settings in Windward

by
Posted on 08/04/2014

Please Share This

 

Citizens of all nations are united in knowing that people from everywhere else are doing it wrong. Whatever “it” happens to be at the time doesn’t really matter. Today, I’m going to address two of the big ones in reporting.

Whether you’re calling that dumpling a potsticker, gyoza, samosa, or empanada, you’re gonna have to pay for it, and you’ll want to know what date you ate it – so let’s talk about dates and currencies!

With a little foresight in template design, you can easily use a single template for every country you operate in, and it’ll match the native formatting for dates and currencies.

How Windward Determines Locales

A single reporting solution for users in many nations can be tricky, but we at Windward can flout national borders with the simple application of locales. Did you know:

  1. That OUT tags have a locale?
  2. And that there’s also a locale for the template itself?
  3. And there’s even a third locale for the system?

Well there are! And when you format an OUT tag, that’s the order Windward looks in.

How to Format Currencies

I’ve got a web app that clients from all over the world log in to. Each of them has their own database instance, each with currency values stored as the currency of choice in their home country. When I run a report, I need to tell that report who’s receiving it so that it will come out using the right formatting. 1000 in the currency field can mean $1,000.00 or it can mean €1.000,00. It all depends what currency they use, and what separators (notice the swapped , and . symbols).

When I’m running a report named “myReport” from my code, I need to tell it who’s running it. I get their country (whether from their user id, something they enter, their ip, etc), and I call myReport.Locale = <their locale>. Just like that, money looks just the way they expect to see it.

 

How to Format Dates

That still leaves me with dates. Here in the US, we expect month/day/year. Nobody else wants it that way. However, substitution here gets a little trickier. Standard format codes follow the standard M for month, d for day, y for year. And when we define a format code, we’ve got to set that in the template.

So how do we switch? We use our trusty standby – the IF tag! The easiest way is to pass a location as a parameter to the template. Then just toss in an IF tag, and if it’s the US, set the formatting in the OUT tag to MM/dd/yyyy. ELSE tag, then an OUT tag set to dd/MM/yyyy. End your IF statement. Need to use it again? Save that puppy as a pod, and it’s always there.

LocaleSettingsDate

A Windward sample template that shows how to use IF tags to conditionally display the right date based on input using IF tags.

So go ahead and use this method to match native dates and currencies. Then you can stop spending your time customizing and enjoy your pierogi!

Please Share This



Author: Logan Miles

Having learned computers from “Hackers” and sales from “Thank You For Smoking,” Logan bridges the gap between the technical and non-technical. As a sales engineer, he enjoys not only solving problems but relating them in some way to the (mostly awful) movies he watches while recovering from skiing or hiking trips, depending on the season.

Other posts by