protected MetaLocale addLikelySubtags ( MetaLocale src ) { // Always return a copy. MetaLocale dst = src . copy ( ) ; // If the locale has all fields populated (language, script, territory) // then do nothing. if ( src . hasAll ( ) ) { return dst ; } // Build a temporary locale for matching and clear the variant since it // is not used for likely subtags. MetaLocale temp = src . copy ( ) ; temp . setVariant ( null ) ; // Iterate over the match flags, from most specific to least. for ( int flags : MATCH_ORDER ) { set ( src , temp , flags ) ; MetaLocale match = likelySubtagsMap . get ( temp ) ; if ( match != null ) { // Use the first match we find. We only replace subtags that // are undefined, copying them from the matched locale. if ( ! dst . hasLanguage ( ) ) { dst . setLanguage ( match . _language ( ) ) ; } if ( ! dst . hasScript ( ) ) { dst . setScript ( match . _script ( ) ) ; } if ( ! dst . hasTerritory ( ) ) { dst . setTerritory ( match . _territory ( ) ) ; } break ; } } return dst ; }
Add likely subtags producing the max bundle ID .