Thursday, June 16, 2011

Avoid the "default" language

Avoid the "default" language, at least as far as the language a project is built in.
Why should you avoid "default"?

When you compile a project "default" means "whatever language the current user is running in". On some OSes this is not a problem as you only have one available language. But on something like OS X where it's dead easy to switch between English, French, or any other installed language, it can be horribly confusing.

You might work in English and your partner might work in French, for example.

Now when you compile the "default" language for dynamic constants it's considered to be English, and when your partner compiles it's considered to be French. What this means is that depending on who builds the project, you or your French partner may be surprised by the results.

Ideally, if a user has their preferences set to list German, French or English, then that user would see the application in French. And if someone else has them set to German, English, French they'd see it in English.

So far so good.

But now when you edit the "default" value for a constant what language do you write them in?
If you write in English and your partner writes in French, you'll have problems. Our first German example above will see some default values in French and some in English and so will the second. Why?

It works this way because "default" is ambiguous for each developer. For the English developer it's English and for the French developer it's French. So which is it for the entire project? The answer is that "it depends".

When "default" is the selected language the created plist for the application requires an entry for the "development region" - what the OS should consider the "default language". And since the project is set to "default" the value used has to be derived from somewhere - and that is the language that the OS is currently using.

You can avoid this in one of two ways.
  1. always explicitly set the language that a project is built in (see Build Settings > Language)
  2. always put in values for each localization in the listing for each localized constant
Ideally you should do both.


Beatrix Willius said...

The default setting is worse than useless. It really should be removed.

Norman said...

At this point "default" is so widely used it would be very hard to remove for several reasons some of which I'd really like to get rid of in the IDE itself.