OSDN Git Service

Treat Latin American locales specially
authorRoozbeh Pournader <roozbeh@google.com>
Tue, 10 Jan 2017 23:24:32 +0000 (15:24 -0800)
committerRoozbeh Pournader <roozbeh@google.com>
Wed, 11 Jan 2017 23:52:08 +0000 (15:52 -0800)
commita192a8ced65ceea8bfe44f0eac6a394cbf80d936
treee8188ef2b11a50e0052cb7af40749fadad32dcea
parent51d34bf06aa67ab5b29c5541e777505ad37907d0
Treat Latin American locales specially

Due to legacy reasons, Android translations of European Spanish were
kept under 'es', while Latin American Spanish translations were kept
under 'es-US'. The combination of this, and the new locale
preference rules in Nougat, resulted in 'es' winning over 'es-US' for
all Latin American locales, since 'es' was a direct ancestor, while
'es-US' was just a fallback.

The changes in Nougat had assumed that app developers would put Latin
American Spanish translations under 'es-419', but that could create a
backward-compatibility problem under older Android versions that did
not support three-digit region codes properly.

This CL keeps the Nougat logic and its locale parent tree, but
special-cases es-US and es-MX to be treated as equivalents of es-419
in cases where they are present and es-419 is not.

Bug: 31545805
Bug: 34126460
Test: unit tests are included
Change-Id: Iab26f41294587ee044685a5a6560520c7cbb06f7
libs/androidfw/LocaleData.cpp
libs/androidfw/tests/ConfigLocale_test.cpp