Example #1
0
 static WikiMagicWordProcessorTest()
 {
     WikiDomain wikiDomain = new WikiDomain("wikipedia");
     WikiLanguage wikiLanguage = new WikiLanguage("English", "en");
     string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     WikiSite = new WikiSite(wikiDomain, wikiLanguage, folder + "\\..\\");
 }
Example #2
0
 static WikiTemplateParseTest()
 {
     WikiDomain wikiDomain = new WikiDomain("wikipedia");
     WikiLanguage wikiLanguage = new WikiLanguage("English", "en");
     string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     WikiSite wikiSite = new WikiSite(wikiDomain, wikiLanguage, folder + "\\..\\");
     config_ = new Configuration(wikiSite);
 }
Example #3
0
 static WikiFrWiktionaryTest()
 {
     WikiDomain wikiDomain = new WikiDomain("wiktionary");
     WikiLanguage wikiLanguage = new WikiLanguage("French", "fr");
     string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     WikiSite wikiSite = new WikiSite(wikiDomain, wikiLanguage, folder + "\\..\\");
     config_ = new Configuration(wikiSite);
 }
Example #4
0
 static Wiki2HtmlTest()
 {
     RootPath = "TestFiles";
     WikiDomain wikiDomain = new WikiDomain("wikipedia");
     WikiLanguage wikiLanguage = new WikiLanguage("English", "en");
     string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     WikiSite wikiSite = new WikiSite(wikiDomain, wikiLanguage, folder + "\\..\\");
     Config = new Configuration(wikiSite);
 }
Example #5
0
        public WikiSite(WikiDomain domain, WikiLanguage language, string folder)
        {
            domain_ = domain;
            language_ = language;

            string langCode = language_.MimeCode ?? language_.Code;
            string moduleFilePath = Path.Combine(folder, MESSAGES);
            string modulefullPath = Path.Combine(moduleFilePath, MESSAGES + langCode + DLL_EXTENTION);
            try
            {
                module_ = new Module(modulefullPath);

                // Languages may fall-back on others. The only Exception is the default language.
                if (string.Compare(language.Code, DEF_LANG_CODE, StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    string fallbackLangCode = module_.GetStringField(FIELD_FALLBACK);
                    if (string.IsNullOrEmpty(fallbackLangCode))
                    {
                        fallbackLangCode = DEF_LANG_CODE;
                    }

                    modulefullPath = Path.Combine(moduleFilePath, MESSAGES + fallbackLangCode + DLL_EXTENTION);
                    Module fallbackModule = new Module(modulefullPath);
                    MergeNamespaces(fallbackModule.GetString2StringMapField(FIELD_NAMESPACE_NAMES));
                    MergeSpecialPageAliases(fallbackModule.GetString2StringsMapField(FIELD_SPECIAL_PAGE_ALIASES));
                    MergeMagicWords(fallbackModule.GetString2StringsMapField(FIELD_MAGIC_WORDS));
                }

                MergeNamespaces(module_.GetString2StringMapField(FIELD_NAMESPACE_NAMES));
                MergeSpecialPageAliases(module_.GetString2StringsMapField(FIELD_SPECIAL_PAGE_ALIASES));
                MergeMagicWords(module_.GetString2StringsMapField(FIELD_MAGIC_WORDS));
            }
            catch
            {
            }

            if (!namespaces_.ContainsKey("NS_WIKIPEDIA"))
            {
                namespaces_["NS_WIKIPEDIA"] = "Wikipedia";
            }

            CurrentNamespace = Namespace.Main;
        }
Example #6
0
 public void Modules()
 {
     WikiDomain wikiDomain = new WikiDomain("wikipedia");
     WikiLanguage wikiLanguage = new WikiLanguage("Aymara", "ay");
     string folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     WikiSite wikiSite = new WikiSite(wikiDomain, wikiLanguage, folder + "\\..\\");
 }
Example #7
0
        public WikiArticleName(string title, WikiLanguage lang)
        {
            Name = title;
            if (lang != null)
            {
                LanguageCode = lang.Code;
                if (!string.IsNullOrEmpty(lang.Name))
                {
                    LanguageName = lang.Name;
                    return;
                }

                if (!string.IsNullOrEmpty(lang.LocalName))
                {
                    LanguageName = lang.LocalName;
                    return;
                }
            }

            LanguageCode = "??";
            LanguageName = "Unknown";
        }