Proposed fix for trac ticket #17155

This is a two parts fix, one in dojo/i18n, one in util/build/tranforms/writeAMD.

The idea is to gather a list of all available locales in the application at build time, so the i18n plugin can decide of the best available locale without doing any http request.

There is two other pull requests for 1.8 branch to account for the different code base.