sameLanguageGroup function
Helper function: checks if two locales share the same language group. Same language group if they have the same language code, or one is a language-only code.
Implementation
bool sameLanguageGroup(String locale1, String locale2) {
final lang1 = getLanguageCode(locale1);
final lang2 = getLanguageCode(locale2);
if (lang1 == lang2) return true;
// Check if either is language-only and matches the other's language code
if (locale1 == lang2 || locale2 == lang1) return true;
return false;
}