Revision: 6168
Author:   russblau
Date:     2008-12-18 14:03:09 +0000 (Thu, 18 Dec 2008)

Log Message:
-----------
Apply changes from trunk

Modified Paths:
--------------
    branches/rewrite/pywikibot/families/wikipedia_family.py
    branches/rewrite/pywikibot/textlib.py

Property Changed:
----------------
    branches/rewrite/pywikibot/families/
    branches/rewrite/pywikibot/family.py


Property changes on: branches/rewrite/pywikibot/families
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/pywikipedia/families:5896-6144
   + /trunk/pywikipedia/families:5896-6165

Modified: branches/rewrite/pywikibot/families/wikipedia_family.py
===================================================================
--- branches/rewrite/pywikibot/families/wikipedia_family.py     2008-12-18 
14:00:32 UTC (rev 6167)
+++ branches/rewrite/pywikibot/families/wikipedia_family.py     2008-12-18 
14:03:09 UTC (rev 6168)
@@ -86,13 +86,14 @@
                     u'Batailles homonymes', u'Cantons homonymes',
                     u'Homonymie de clubs sportifs', u'Homonymie dynastique',
                     u'Homonymie de comtés', u'Internationalisation',
-                    u'Isomérie', u'Homonymie de nom romain',u'Sigle',
+                    u'Isomérie', u'Homonymie de nom romain',
                     u'Paronymie', u'Patronyme', u'Personnes homonymes',
                     u'Unités homonymes', u'Villes homonymes'],
             'frp': [u'Homonimos'],
             'fy':  [u'Tfs', u'Neibetsjuttings'],
             'ga':  [u'Idirdhealú', u'Disambig'],
             'gl':  [u'Homónimos', u'Disambig'],
+            'gv':  [u'Reddaghey'],
             'he':  [u'פירושונים', u'Disambig'],
             'hi':  [u'बहुविकल्पी शब्द', u'Disambig',],
             'hr':  [u'Disambig', u'Razdvojba'],
@@ -113,14 +114,14 @@
             'ko':  [u'Disambig', u'동음이의', u'동음이의어'],
             'ku':  [u'Cudakirin'],
             'kw':  [u'Klerheans'],
-            'ksh': [u'Disambig',  u'disambig'],
+            'ksh': [u'Disambig'],
             'la':  [u'Discretiva', u'Disnomen'],
             'lb':  [u'Homonymie', u'Disambig'],
             'li':  [u'Verdudeliking', u'Verdudelikingpazjena', u'Vp'],
             'lmo': [u'Desambiguació'],
             'ln':  [u'Bokokani'],
             'lt':  None,
-            'mk':  [u'Појаснување'],
+            'mk':  [u'Појаснување', u'Disambig'],
             'mo':  [u'Дезамбигуйзаре', u'Disambig'],
             'ms':  [u'Nyahkekaburan', u'Disambig'],
             'mt':  [u'Diżambigwazzjoni'],
@@ -138,6 +139,7 @@
             'pl':  [u'Disambig', u'DisambRulers', u'DisambigC', u'Strona 
ujednoznaczniająca'],
             'pms': [u'Gestion dij sinònim'],
             'pt':  [u'Desambiguação', u'Disambig', u'Desambig'],
+            'qu':  [u"Sut'ichana qillqa", u'Disambig', u'SJM'],
             'rmy': [u'Dudalipen'],
             'ro':  [u'Dezambiguizare', u'Disambig', u'Hndis', u'Dez'],
             'ru':  [u'Disambig', u'Неоднозначность', u'неоднозначность',
@@ -151,12 +153,14 @@
             'sk':  [u'Disambig', u'Rozlišovacia stránka', u'Disambiguation'],
             'sl':  [u'Disambig', u'Razločitev', u'Disambig-ship', 
u'Disambig-unit'],
             'sq':  [u'Kthjellim', u'Disambig'],
-            'sr':  [u'Вишезначна одредница', u'Disambig', u'Вишезначна'],
+            'sr':  [u'Вишезначна одредница', u'Disambig', u'Вишезначна',
+                    u'Višeznačna odrednica'],
             'srn': [u'Dp'],
             'su':  [u'Disambig'],
             'sv':  [u'Betydelselista', u'Disambig', u'Förgrening', u'Gaffel',
                     u'Efternamn', u'Gren', u'Förgreningssida', u'3LC',
-                    u'Trebokstavsförkortning', u'TLAdisambig'],
+                    u'Trebokstavsförkortning', u'TLAdisambig', u'4LA',
+                    u'Trebokstavsförgrening'],
             'sw':  [u'Maana'],
             'ta':  [u'பக்கவழி நெறிப்படுத்தல்'],
             'te':  [u'అయోమయ నివృత్తి', u'వివరమైన అయోమయ నివృత్తి'],
@@ -164,7 +168,8 @@
             'th':  [u'แก้กำกวม', u'Disambig'],
             'tl':  [u'Paglilinaw', u'Disambig'],
             'tr':  [u'Anlam ayrım', u'Disambig', u'Anlam ayrımı'],
-            'uk':  [u'Неоднозначність',u'DisambigG', u'Disambig', 
u'DisambigN'],
+            'uk':  [u'Неоднозначність',u'DisambigG', u'Disambig', u'DisambigN',
+                    u'Багатозначність'],
             'vec': [u'Disambigua'],
             'vi':  [u'Trang định hướng', u'Định hướng', u'Disambig', u'Hndis'],
             'vls': [u'Db', u'Dp', u'Dpintro'],


Property changes on: branches/rewrite/pywikibot/family.py
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/pywikipedia/family.py:6057-6144
   + /trunk/pywikipedia/family.py:6057-6165

Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py       2008-12-18 14:00:32 UTC (rev 
6167)
+++ branches/rewrite/pywikibot/textlib.py       2008-12-18 14:03:09 UTC (rev 
6168)
@@ -310,20 +310,22 @@
     s = interwikiFormat(new, insite = site)
     s2 = removeLanguageLinks(oldtext, site = site, marker = marker)
     if s:
+        separator = site.family.interwiki_text_separator
         if site.language() in site.family.interwiki_attop:
-            newtext = s + site.family.interwiki_text_separator + 
s2.replace(marker,'').strip()
+            newtext = s + separator + s2.replace(marker,'').strip()
         else:
             # calculate what was after the language links on the page
             firstafter = s2.find(marker) + len(marker)
-            # Is there any text in the 'after' part that means we should keep 
it after?
+            # Any text in 'after' part that means we should keep it after?
             if "</noinclude>" in s2[firstafter:]:
                 newtext = s2[:firstafter] + s + s2[firstafter:]
             elif site.language() in site.family.categories_last:
                 cats = getCategoryLinks(s2, site = site)
-                s2 = removeCategoryLinks(s2.replace(marker,'').strip(), site) 
+ site.family.interwiki_text_separator + s
+                s2 = removeCategoryLinks(s2.replace(marker,'').strip(),
+                                         site) + separator + s
                 newtext = replaceCategoryLinks(s2, cats, site=site)
             else:
-                newtext = s2.replace(marker,'').strip() + 
site.family.interwiki_text_separator + s
+                newtext = s2.replace(marker,'').strip() + separator + s
             newtext = newtext.replace(marker,'')
     else:
         newtext = s2.replace(marker,'')
@@ -494,19 +496,21 @@
         s2 = removeCategoryLinks(oldtext, site = site, marker = marker)
 
     if s:
+        separator = site.family.category_text_separator
         if site.language() in site.family.category_attop:
-            newtext = s + site.family.category_text_separator + s2
+            newtext = s + separator + s2
         else:
             # calculate what was after the categories links on the page
             firstafter = s2.find(marker)
-            # Is there any text in the 'after' part that means we should keep 
it after?
+            # Any text in 'after' part that means we should keep it after?
             if "</noinclude>" in s2[firstafter:]:
                 newtext = s2[:firstafter] + s + s2[firstafter:]
             elif site.language() in site.family.categories_last:
-                newtext = s2.replace(marker,'').strip() + 
site.family.category_text_separator + s
+                newtext = s2.replace(marker,'').strip() + separator + s
             else:
                 interwiki = getLanguageLinks(s2)
-                s2 = removeLanguageLinks(s2.replace(marker,''), site) + 
site.family.category_text_separator + s
+                s2 = removeLanguageLinks(s2.replace(marker,''), site
+                                         ) + separator + s
                 newtext = replaceLanguageLinks(s2, interwiki, site)
         newtext = newtext.replace(marker,'')
     else:
@@ -673,3 +677,147 @@
             result.append((name, params))
     return result
 
+# I18N functions
+
+# Languages to use for comment text after the actual language but before
+# en:. For example, if for language 'xx', you want the preference of
+# languages to be:
+# xx:, then fr:, then ru:, then en:
+# you let altlang return ['fr','ru'].
+# This code is used by translate() below.
+
+def _altlang(code):
+    """Define fallback languages for particular languages.
+
+    If no translation is available to a specified language, translate() will
+    try each of the specified fallback languages, in order, until it finds
+    one with a translation, or '_default' as a last resort.
+
+    """
+    if code=='aa':
+        return ['am']
+    if code in ['fa','so']:
+        return ['ar']
+    if code=='ku':
+        return ['ar','tr']
+    if code=='sk':
+        return ['cs']
+    if code in ['bar','ksh','stq']:
+        return ['de']
+    if code in ['als','lb']:
+        return ['de','fr']
+    if code=='dsb':
+        return ['hsb','de']
+    if code=='hsb':
+        return ['dsb','de']
+    if code=='io':
+        return ['eo']
+    if code in ['an','ast','ay','ca','gn','nah','qu']:
+        return ['es']
+    if code == ['cbk-zam']:
+        return ['es','tl']
+    if code=='eu':
+        return ['es','fr']
+    if code in ['glk','mzn']:
+        return ['fa','ar']
+    if code=='gl':
+        return ['es','pt']
+    if code=='lad':
+        return ['es','he']
+    if code in ['br','ht','kab','ln','lo','nrm','wa']:
+        return ['fr']
+    if code in ['ie','oc']:
+        return ['ie','oc','fr']
+    if code in ['co','frp']:
+        return ['fr','it']
+    if code=='yi':
+        return ['he','de']
+    if code=='sa':
+        return ['hi']
+    if code in ['eml','lij','lmo','nap','pms','roa-tara','sc','scn','vec']:
+        return ['it']
+    if code=='rm':
+        return ['it','de','fr']
+    if code in ['bat-smg','ltg']:
+        return ['lt']
+    if code=='ia':
+        return ['la','es','fr','it']
+    if code=='nds':
+        return ['nds-nl','de']
+    if code=='nds-nl':
+        return ['nds','nl']
+    if code in ['fy','pap','vls','zea']:
+        return ['nl']
+    if code=='li':
+        return ['nl','de']
+    if code=='csb':
+        return ['pl']
+    if code in ['fab','tet']:
+        return ['pt']
+    if code in ['mo','roa-rup']:
+        return ['ro']
+    if code in ['av','bxr','cv','hy','lbe','tg','udm','uk','xal']:
+        return ['ru']
+    if code in ['be','be-x-old']:
+        return ['be','be-x-old','ru']
+    if code in ['ky','tt','uz']:
+        return ['kk','tr','ru']
+    if code in ['az','diq','tk','ug']:
+        return ['tr']
+    if code in ['ja','minnan','zh','zh-cn']:
+        return ['zh','zh-tw','zh-classical','zh-cn']
+    if code in 
['bo','cdo','hak','wuu','za','zh-cdo','zh-classical','zh-tw','zh-yue']:
+        return ['zh','zh-cn','zh-classical','zh-tw']
+    if code=='da':
+        return ['nb','no']
+    if code in ['is','no','nb','nn']:
+        return ['no','nb','nn','da','sv']
+    if code=='sv':
+        return ['da','no','nb']
+    if code=='se':
+        return ['no','nb','sv','nn','fi','da']
+    if code in ['bug','id','jv','map-bms','ms','su']:
+        return ['id','ms','jv']
+    if code in ['bs','hr','sh']:
+        return ['sh','hr','bs','sr']
+    if code in ['mk','sr']:
+        return ['sh','sr','hr','bs']
+    if code in ['ceb','pag','tl','war']:
+        return ['tl','es']
+    if code=='bi':
+        return ['tpi']
+    if code=='tpi':
+        return ['bi']
+    if code == 'new':
+        return ['ne']
+    if code == 'nov':
+        return ['io','eo']
+    return []
+
+def translate(code, xdict):
+    """Return the most appropriate translation from a translation dict.
+
+    Given a language code and a dictionary, returns the dictionary's value for
+    key 'code' if this key exists; otherwise tries to return a value for an
+    alternative language that is most applicable to use on the Wikipedia in
+    language 'code'.
+
+    The language itself is always checked first, then languages that
+    have been defined to be alternatives, and finally English. If none of
+    the options gives result, we just take the first language in the
+    list.
+
+    """
+    # If a site is given instead of a code, use its language
+    if hasattr(code,'lang'):
+        code = code.lang
+
+    if xdict.has_key(code):
+        return xdict[code]
+    for alt in _altlang(code):
+        if xdict.has_key(alt):
+            return xdict[alt]
+    if xdict.has_key('en'):
+        return xdict['en']
+    return xdict.values()[0]
+



_______________________________________________
Pywikipedia-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

Reply via email to