Menu

GetAllLanguages

Help
2015-01-16
2015-01-29
  • Juergen Thomas

    Juergen Thomas - 2015-01-16

    Site.language returns the site's language, of course. Is there a simple way to get a List<string> or string[] with all language abbreviations of ISO 639 that are used by WMF projects (including projects like simple and zh-min-nan)?

    Of course, it's no problem to get such a list by copy&paste from different Wikipedia or Wikimedia sites and include the list into the bot's source code. IMHO it's a better programmatical way to fill the list inside the application by a Site method. Juergen

     
  • CodeDriller

    CodeDriller - 2015-01-24

    In the variable

    yourSiteObj.generalData["interwiki"]

    you can find all interwiki codes that are recognized locally, delimited by '|' character.
    These include not only the language codes but also tags like "betawikiversity".

     
  • Juergen Thomas

    Juergen Thomas - 2015-01-27

    Thank you. Site.generalData["interwiki"] works but it isn't a proper way (like you told). A better way could be

    Site.GetWikimediaProjects(true)
    

    All the different prefixes give a list of used language abbreviations. Juergen

     
  • CodeDriller

    CodeDriller - 2015-01-27

    Execuse me, I don't quite understand. What different prefixes must give a list of language abbreviations? What the resultant list should look like?

     
  • Juergen Thomas

    Juergen Thomas - 2015-01-28

    I mean prefixes like these (as combined string - with colons or without):

    aa|ab|af|...|de|en|ru|simple|...|zh-min-nan|zh-yue|zu
    

    The following items of Site.generalData["interwiki"] don't belong to the list of languages:

    acronym|advisory|advogato|...
    

    Juergen

     
  • CodeDriller

    CodeDriller - 2015-01-28

    Then wouldn't it be better to find relevant items in GetWikimediaProjects()? The following code will do the job:

    var langs = (from s in siteObj.GetWikimediaProjects(true)
        where Bot.CountMatches(s, ".", false) == 2
        select s.Substring(0, s.IndexOf('.'))).Distinct().ToList();
    
     

    Last edit: CodeDriller 2015-01-29
  • Juergen Thomas

    Juergen Thomas - 2015-01-29

    GetWikimediaProjects() was my proposal two contribs ago. Thank you for the full code. (I don't know anything about LINQ and should use a loop instead of.) Juergen

    PS. Is there a way to declare a thread finished?

     
    • CodeDriller

      CodeDriller - 2015-01-29

      Maybe like this:

      THREAD IS FINISHED !!!
      

      :-)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.