private RepoTreeItem FilterByLanguage(ILoadedRepository repo)
 {
     return(FilterByTagPrefix(repo, "lang:", tag => {
         var langTag = tag.Substring(5);
         var r = Iso639.GetTag(langTag);
         return $"{Util.Util.GetCultureDisplayName(langTag)} [{langTag}]";
     }));
 }
        private LanguageTag LanguageTag(string tag)
        {
            var data        = Iso639.GetTag(tag);
            var simplestTag = data?.Tag1 ?? data?.Tag3 ?? tag;
            var name        = data?.Autonym ?? data?.Name ?? tag;

            return(new LanguageTag {
                Name = name, Tag = simplestTag
            });
        }
        public static string GetCultureDisplayName(string tag)
        {
            if (tag == "zxx" || tag == "")
            {
                return("---");
            }

            string      langCode;
            CultureInfo?culture = null;

            try {
                culture  = new CultureInfo(tag);
                langCode = culture.ThreeLetterISOLanguageName;
            }
            catch (Exception) {
                // Best attempt
                langCode = tag.Split('_', '-')[0];
            }

            if (langCode == string.Empty)
            {
                langCode = tag;
            }

            var data = Iso639.GetTag(langCode);

            if (data?.Autonym != null && data.Autonym != "")
            {
                return(data.Autonym);
            }

            if (culture != null && culture.DisplayName != "" && culture.DisplayName != culture.EnglishName)
            {
                return(culture.DisplayName);
            }

            if (data?.Name != null && data.Name != "")
            {
                return(data.Name);
            }

            return(tag);
        }