[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-i18n-doc
Subject:    Re: Translations for Mimetyps e.g. in kdelibs/xml_mimetypes not working?
From:       Burkhard =?ISO-8859-1?Q?L=FCck?= <lueck () hube-lueck ! de>
Date:       2014-02-13 9:50:17
Message-ID: 4584518.YGTp6gh4zW () parodia
[Download RAW message or body]

Am Sonntag, 22. Dezember 2013, 15:32:46 schrieb Albert Astals Cid:
> El Diumenge, 22 de desembre de 2013, a les 15:26:35, Burkhard Lück va
> escriure:
> > Hi,
> > 
> > Commit log for kde.xml Revision 644191 says:
> > <quote>
> > Remove old-style .desktop files, and turn them into a kde.xml file
> > [snip]
> > During make install, update-mime-database is run to process kde.xml
> > </quote>
> > 
> > But apparently this does not work properly,
> > 
> > Looking at the shared-mime-info-1.2 tarball I found a file HACKING which
> > says: <quote>
> > Releasing
> > ---------
> > - Run "make update-translations" and "make check-translations" before
> > release </quote>
> > 
> > This apparently generates the file freedesktop.org.xml and add all
> > translations from the po folders for a mime type definition e.g.:
> > <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
> > 
> >   <mime-type type="application/andrew-inset">
> >   
> >     <comment>ATK inset</comment>
> >     <comment xml:lang="ar">شكل ATK</comment>
> > 
> > [snip]
> > 
> >     <acronym>ATK</acronym>
> >     <expanded-acronym>Andrew Toolkit</expanded-acronym>
> >     <generic-icon name="x-office-document"/>
> >     <glob pattern="*.ez"/>
> >   
> >   </mime-type>
> > 
> > The last step is apparently missing in kde or am I completely wrong here?
> 
> Yes it has never worked.
> 
Attached a python script to fill a file like kde.xml with the our translations

Tested with kde.xml  in kdelibs and geo.xml in marble, where message 
extraction works.

At the top of the script is comment with a list of all mimetype xml files known 
to me and their extraction status.

The script needs a python module to get the msgstr for a given msgid from a po 
file. So far I have used my own python module checkutils4, but the script could 
use any other module (pology? or a python library from distribution) able to 
return a msgstr from a po file.

To include the script into scripty's workflow and make it fully functional, it 
needs some tweaking (works for now only for kde main modules, not for 
extragear + playground, does not overwrite the original xml file etc), but that 
should not be difficult.

Using this script should make our translations usable at least with packages 
installed from distribution, does anyone know how this works for self compiled 
apps/modules?
  
-- 
Burkhard Lück
["checkkdexml-dict.py" (checkkdexml-dict.py)]

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, os, re, glob
from checkutils4 import *
"""
kdelibs/mimetypes/kde.xml + XmlMessages.sh -> xml_mimetypes.po
kdeedu/marble/data/mimetypes/geo.xml + XmlMessages.sh -> marble_xml_mimetypes.po
frameworks/kcoreaddons/src/mimetypes/kde5.xml + XmlMessages.sh -> \
marble_xml_mimetypes.po

kdegames/kpat/mimetypes/kpatience.xml - no XmlMessages.sh
kdegames/palapeli/mime/palapeli-mimetypes.xml - no XmlMessages.sh
kdesdk/okteta/mimetypes/okteta.xml - no XmlMessages.sh
playground/graphics-git/cirkuit/src/mimetypes/cirkuit.xml - no XmlMessages.sh
playground/multimedia-git/kdenlive/src/mimetypes/kdenlive.xml - no XmlMessages.sh
playground/multimedia-git/kdenlive/src/mimetypes/westley.xml - no XmlMessages.sh
playground/utils/khtml_userscript/mimetype_userscript.xml - no XmlMessages.sh
extragear/base-git/bluedevil/src/bluedevil-mime.xml  - no XmlMessages.sh -> \
https://bugs.kde.org/show_bug.cgi?id=329105 """
if len(sys.argv) != 4:
  print '\nUsage: cd module + python %s path/to/xmlfile path/to/l10ndir/ pofilename' \
%os.path.basename(sys.argv[0]) else:
  xmlfilepath, xmlfilename, l10ndirpath, pofilename = sys.argv[1], \
sys.argv[1].split("/")[-1], sys.argv[2], sys.argv[3]  \
l10nmodulename=os.getcwd().split('/')[-1]  begincommenttag="<comment>"
  endcommenttag="</comment>"
  begincommentlangtag='<comment xml:lang='

  xmllines=codecs.open(xmlfilepath,"rb","utf8").readlines()
  xmlwithtranslation=''
  xmlpofilelist=glob.glob("%s/*/messages/%s/%s" %(l10ndirpath, l10nmodulename, \
pofilename))  
  pofiledict={}
  for pofile in xmlpofilelist:
    langcode=pofile.split(l10ndirpath)[1].split("/")[0]
    if langcode != "x-test":
      po=guidocpo(pofile)
      pofiledict[langcode]=po
  
  for line in xmllines:
    if begincommenttag in line:
      indentwidth=line.split(begincommenttag)[0]
      xmlwithtranslation += line
      msgid=line.split(begincommenttag)[1].split(endcommenttag)[0]
      for lang, po in sorted(pofiledict.iteritems()):
        msgstr=pofiledict[lang].get_msgstr(msgid)
        if msgstr!='':
          transline='%s%s"%s">%s%s\n' %(indentwidth, begincommentlangtag, lang, \
msgstr, endcommenttag)  xmlwithtranslation += transline
    elif begincommentlangtag in line:
      pass
    else:
      xmlwithtranslation += line
      
  modifiedxml=codecs.open("%s.po" %xmlfilepath,"w","utf8") # do not overwrite xmlfile \
so far, check for valid xml?  modifiedxml.write(xmlwithtranslation)
  modifiedxml.close()



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic