/// <summary> /// Initializes a new instance of the <see cref="LanguageLookup"/> class. /// It gets its data from the LanguageDataIndex resource /// </summary> public LanguageLookup() { Sldr.InitializeLanguageTags(); // initialise SLDR language tags for implicit script codes string langTagsContent = LanguageRegistryResources.langTags; // The cached file is renamed if it's invalid during Sldr.InitializeLanguageTags(). var cachedAllTagsPath = Path.Combine(Sldr.SldrCachePath, "langtags.json"); if (File.Exists(cachedAllTagsPath)) { langTagsContent = RobustFile.ReadAllText(cachedAllTagsPath); } List <AllTagEntry> rootObject = JsonConvert.DeserializeObject <List <AllTagEntry> >(langTagsContent); foreach (AllTagEntry entry in rootObject) { // tags starting with x- have undefined structure so ignoring them as well as deprecated tags // tags starting with _ may provide some sort of undefined variant information, but we ignore them as well if (!entry.deprecated && !entry.tag.StartsWith("x-", StringComparison.Ordinal) && !entry.tag.StartsWith("_", StringComparison.Ordinal)) { AddLanguage(entry.tag, entry.iso639_3, entry.full, entry.name, entry.localname, entry.region, entry.names, entry.regions, entry.tags, entry.iana, entry.regionName); } } AddLanguage("qaa", "qaa", "qaa", "Unlisted Language"); }
/// <summary> /// Initializes a new instance of the <see cref="LanguageLookup"/> class. /// It gets its data from the LanguageDataIndex resource /// </summary> public LanguageLookup() { Sldr.InitializeLanguageTags(); // initialise SLDR language tags for implicit script codes string allTagsContent = LanguageRegistryResources.alltags; List <AllTagEntry> rootObject = JsonConvert.DeserializeObject <List <AllTagEntry> >(allTagsContent); foreach (AllTagEntry entry in rootObject) { if (!entry.deprecated && !entry.tag.StartsWith("x-")) // tags starting with x- have undefined structure so ignoring them as well as deprecated tags { AddLanguage(entry.tag, entry.iso639_3, entry.full, entry.name, entry.localname, entry.region, entry.names, entry.regions, entry.tags); } } AddLanguage("qaa", "qaa", "qaa", "Unlisted Language"); }