l18N - language fallback

I think it would be a good idea to provide a fallback for localized views.

Imagine your sourceLanguage is "en_us" and you would like to provide german views. You could place them within a "de_de" subdirectory. Someone visiting your website from austria, who might have "de_at" configured as preferred language would end up with the english default view, although the "de_de" localization might be better suited for him.

So, if a fallback existed, one could place the views under a general "de" subdirectory and everyone visiting the website with a preferred language like "de_de", "de_at", "de_ch", … would be serverd these views instead of the english ones.

I just came across that, because IE8 seems to be preconfigured with a preferred language "de" instead of "de_de" which is the one I'm using with FireFox.

I totally agree. There might not be many differences, but sometimes regional wording might be necessary.

You cannot trust the language preference from end users.

If you have an application supporting multiple languages, you should know what languages it supports. Then given a user language preference, you may resolve it into a known language. You should performance this process using your own procedure.

Well, the point is: 99.9% of the words might be the same in germany, austria and switzerland. so it does not make any sense to maintain different translation files for 3 regions just because of a few words. the point is, that the austrian (de_at) translation just defines a few keys and should fall back to "de" if no regional translation exists.

Is there such a fallback available now? The file /framework/i18n/data/de.php (-> german) contains the following array for the wide month names:




    array (

      1 => 'Januar',

      2 => 'Februar',

      3 => 'März',

      4 => 'April',

      5 => 'Mai',

      6 => 'Juni',

      7 => 'Juli',

      8 => 'August',

      9 => 'September',

      10 => 'Oktober',

      11 => 'November',

      12 => 'Dezember',

    ),



da_at.php contains just the different month name of the january in austrian german:




    array (

      1 => 'Jänner',

    ),



Now Yii::app()->getLocale()->monthNames contains only array(1 => ‘Jänner’) when language is set to de_at.

Is this a bug in the data or a bug in the source or am I using it wrong?