Locations of visitors to this page
    Sprouting Synapses       Minimize  

             
            Minimize  
Author: SkySigal Created: 8/22/2008 6:14 PM
Posts about Globalization, CultureInfo, etc.

By SkySigal on 10/21/2008 3:19 PM

image

Appears that I've found a book to my liking:

.NET Internationalization: The Developer's Guide by Guy Smith-Ferrier

I first came across it here:

http://www.developerfusion.com/book/7017/net-internationalization-the-developers-guide/

powered by metaPost

By SkySigal on 10/20/2008 11:45 PM

Straight from the Horse's Mouth...

Links to keep (a very complete set of reading material).

 

Link:

powered by metaPost

By SkySigal on 10/20/2008 6:11 PM

Over the years, I've found that breaking resources into several files saves time.

Multiple Resource Files
I use the following list as a starting point:

  • Local Resources:
    • Personally, I try my best to use Global resources as much as possible so that translations are not missed in the rush to release -- but invariably Global resources are not ready/finalized enough to rely on them by the time I need them.
  • Navigation.resx
    • Examples being: Go, Forward, Back, Next, Stop, Pause, etc.
    • These types of strings are usually the same for most programs so once defined, and translated, end up being just a copy, paste job between existing applications and new ones.
    • Although, in practice, this often ends up often merged together with:
  • Menu.resx
    • Examples being: &File,&Open, &Edit, &Cut, &Copy, &Tools, &Help
    • Most of these strings are usually the same for most programs so once defined, and translated, and so start off being just a copy, paste job between existing applications and new ones.
  • Messages.resx: for shared messages (and optionally error messages, in small programs).
    • Examples being: "The file '{0}' has been downloaded.", "Total: {0:C}", etc.
    • Mostly custom per program.
  • ErrorMessages.resx: for shared error messages.
    • Examples being: "Could not open the following file: '{0}'."
    • Some error messages are quite common.
  • Glossary.resx:
    • Examples being: "Note", "Contact", "Email", etc.
    • Definitely specific to an application.
  • Configuration.resx
    • FileNames, etc. not translated. Only used by developers.
    • This can be argued that if not translated, why use a resource file for it (to keep a consistent approach, and modifiable prior to release).

Caching
Caching is a necessity -- but in a multicultural website, make sure you cache based on culture.

 

Four Cultures at Play:

Another point I would like to make is to use at least 3 cultures when programming -- and 4 Cultures would be even better:

  • Set UICulture in order for the Framework to pull up the correct resources for visible UI strings and images.
  • Set Culture in order for the Framework to correctly format dates, and numbers, as well as sort data.
  • Use Culture for round tripping strings to visible text and back (ie new ListItem(data.ToString()),
    or better still, Culture and CultureInfo.InvariantCulture to round trip data(ie: new ListItem(data.ToString(), data.ToString(CultureInfo.InvariantCulture)).
  • Use a custom _TransactionCulture for currencies -- it is is a culture neutral to both the client and server's culture.

Note:
The only one that can appear to be perplexing for a second is when trying to parse the value of eg: a TextBox that you've used to enter a Currency Value -- but note that you are actually not parsing a currency, but just a float, so its simpler: just parse it with the CurrentCulture, and then rendered ToString() using _TransactionCulture.
Note:
The reason for a slight preference towards using InvariantCulture for roundtripping data is that things can go wonky if the page was initially rendered using one Locale, and the region is changed on a Postback. 

Note:
Not everyone will agree with me that Culture should be set to be the same as UICulture (see: http://msdn.microsoft.com/fr-fr/magazine/cc163609(en-us).aspx)

Note:
One way of to consider creating a TransactionCulture that has the commas/dots in the same format as the UICulture, but with the current currency symbol, would be to start with something like:

_TransactionCulture = CultureInfo.UICurrentCulture.Clone() 
   as CultureInfo; _TransactionCulture.NumberFormat.CurrencySymbol = "€ "; //and maybe more work to deal with number of
//decimal point, etc....

Did I miss something..?

Links:

 


Note:This is just a cut/paste from the much larger post that I did on globalization, in order to make it more readily accessible/linkable to from

powered by metaPost

By SkySigal on 10/20/2008 5:51 PM

The Client's Point of View.

The old phrase "The client is King!" sums up succinctly the need for globalization: you may have written the website in the US, but a French client would much prefer to visit your website in a language he can understand. 
This is where Globalization and Localization comes in.

Globalization (format) versus Localization (resources)

The two words are used so often together that they turn into a blurry phrase rather than being distinct subjects...let's try to sort that out first.

Although they are very tightly related, and partially overlap, the two concepts are distinct.

  • Globalization as the process of designing and developing software to work in various cultures:
    • formatting most (not all) output according to the client's UICulture, while formatting specific outputs (usually currency) in another Culture.
    • designing layouts for more than just yo Read More »

By SkySigal on 8/23/2008 5:51 PM

image Not so long ago, designing software so that it could be translated to french involved custom solutions, hell, and a lot of funny translations.

Now, making your software so that it formats Dates, Time, Numbers, Currency for each country really is about as easy as it can get.

Here's how...

 

Read More »

By SkySigal on 8/23/2008 1:31 AM

blog_csharp_globalization The kind of stuff I would totally forget till about 3 months after I've shipped!

<<<

If you need to use custom format for negative float numbers or zero, use semicolon separator;“ to split pattern to three sections. The first section formats positive numbers, the second section formats negative numbers and the third section formats zero. If you omit the last section, zero will be formatted using the first section.

[C#]

String.Format("{0:0.00;minus 0.00;zer
         
          Read More »
          
        

By SkySigal on 8/23/2008 1:21 AM

 blog_csharp_globalizationSince I had the code there from the previous post, and it would take me only 2 minutes to rewire it, I'm also including these outputs in case its ever useful:

Read More »

By SkySigal on 8/23/2008 12:43 AM

blog_csharp_globalization I'm ALWAYS forgetting how to format a double into a currency or percentage...

And I output to scientific format once every 10 years, so I definitely always have to look that up as well...

And hex...hex...!

So here is a print out showing formats, plus their output for all the ones I could possibly ever need:

 

Read More »


             
Copyright 2007 by Sky Sigal