adding j20n2inline trunk
authorZbigniew Braniecki <gandalf@mozilla.com>
Mon, 23 Aug 2010 13:40:31 +0200
branchtrunk
changeset 439 c4892f86b64559d940cef102a63f51c57a109a6e
parent 438 b1dd85aefac7cb67ab1cec5f6edeb2191b87cfcc
child 440 d029c9ab7beb3d204523a8a683f22332ad9e2d2b
push id22
push userzbraniecki@mozilla.com
push dateMon, 23 Aug 2010 14:01:03 +0000
adding j20n2inline
scripts/l20n/regression/data.py
scripts/l20n/regression/xul.py
--- a/scripts/l20n/regression/data.py
+++ b/scripts/l20n/regression/data.py
@@ -31,16 +31,19 @@ files = []
 files.append({
     'type': 'xul',
     'path': 'browser/base/content/browser.xul',
     'dtds': [
         'browser/locales/en-US/chrome/browser/browser.dtd',
         'other-licenses/branding/firefox/locales/en-US/brand.dtd',
         'toolkit/locales/en-US/chrome/global/customizeToolbar.dtd',
     ],
+    'j20ns': [
+        'browser/locales/en-US/chrome/browser/browser.j20n',
+    ],
     'hooks': {
         'pre': preprocess_browser_xul
     }
 })
 files.append({
     'type': 'xul',
     'path': 'browser/base/content/macBrowserOverlay.xul',
     'dtds': [
--- a/scripts/l20n/regression/xul.py
+++ b/scripts/l20n/regression/xul.py
@@ -5,19 +5,20 @@ import os
 sys.path.append('../../../../silme/lib')
 
 import silme.core
 import silme.io
 import silme.format
 
 from data import files
 
-silme.format.Manager.register('dtd')
+silme.format.Manager.register('dtd', 'l20n')
 
 base_path = '/Users/zbraniecki/projects/mozilla/mozilla-central'
+base_path2 = '/Users/zbraniecki/projects/mozilla/mozilla-central-l20n'
 
 patterns = {
     'xml_entity': re.compile(r'\&([^;\n]+);', re.I),
     'l10n_id': re.compile(r'l10n_id="([^"]+)"', re.I),
 }
 
 skip_entities = [
     'amp',
@@ -58,27 +59,40 @@ def dtd2inline(xul, elist):
 
 def j20n2inline(xul, elist):
     pt = 0
     match = patterns['l10n_id'].search(xul)
     while match:
         eid = match.group(1)
         pt = match.end(0)
         if eid in elist:
-            params = 'foo'
+            params = ' '.join(['%s="%s"' % (i,v) for i,v in elist[eid].kvplist.items()])
             xul = '%s%s%s' % (xul[:match.start(0)],
                               params,
                               xul[match.end(0):])
             pt += len(params)-len(match.group(0))
         else:
             print 'ERROR: Missing entity "%s"' % eid
         match = patterns['l10n_id'].search(xul, pt)
     return xul
 
 def main():
+    xul_path = files[0]['path']
+    j20n_path = files[0]['j20ns']
+    xul = io.get_source(os.path.join(base_path2, xul_path))[0]
+    import silme.format.l20n.structure
+    elist = silme.format.l20n.structure.LOL()
+    for path in j20n_path:
+        elist2 = io.get_structure(os.path.join(base_path2, path))
+        print elist2.keys()
+        elist += elist2
+    res = j20n2inline(xul, elist)
+    #print res
+
+    return 
     for file in files:
         xul_path = file['path']
         dtd_path = file['dtds']
         xul = io.get_source(os.path.join(base_path, xul_path))[0]
         if 'hooks' in file and 'pre' in file['hooks']:
             xul = file['hooks']['pre'](xul, base_path)
         
         elist = silme.core.EntityList()