code: private static String getFallbackString(String fallback) {
          int extStart = fallback.indexOf('@');
          if (extStart == -1) {
              extStart = fallback.length();
          }
          int last = fallback.lastIndexOf('_', extStart);
          if (last == -1) {
              last = 0;
          } else {
              // truncate empty segment
              while (last > 0) {
                  if (fallback.charAt(last - 1) != '_') {
                      break;
                  }
                  last--;
              }
          }
          return fallback.substring(0, last) + fallback.substring(extStart);
      }
docs: Returns the given (canonical) locale id minus the last part before the tags.