Changeset 550acf in indico


Ignore:
Timestamp:
03/26/10 09:04:56 (3 years ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
42572c
Parents:
c6839d
git-author:
Jose Benito <jose.benito.gonzalez@…> (03/25/10 19:33:51)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (03/26/10 09:04:56)
Message:

[FIX] i18n problems with badge creation

All the items (elements inside a badge) were storing
their name (translated or not) in the DB. Now, we use
a key and a dictionary JS in order to translate the
names.

Location:
indico/MaKaC
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/PDFinterface/conference.py

    r019367 r550acf  
    27312731        # We draw the items of the badge 
    27322732        for item in self.__badgeTemplate.getItems(): 
    2733  
    27342733            # First we determine the actual text that has to be drawed. 
    2735             action = BadgeDesignConfiguration().items_actions[item.getName()] 
     2734            action = BadgeDesignConfiguration().items_actions[item.getKey()][1] 
    27362735            if isinstance(action, str): 
    27372736                # If for this kind of item we have to draw always the same string, let's draw it. 
  • indico/MaKaC/badge.py

    r9881d7 r550acf  
    199199        Useful so that javascript can analyze it on its own. 
    200200        """ 
     201 
     202        # ensure that each item's got a key (in order to avoid 
     203        # using the name as key). 
     204        for item in self.__templateData[4]: 
     205            itemName = item['name'] 
     206            if not "key" in item: 
     207                item['key'] = itemName 
     208        ############################## 
     209 
    201210        return self.__templateData 
    202211 
     
    385394        self.__badgeTemplate = badgeTemplate 
    386395 
    387     def getName(self): 
    388         """ Returns the name of the item. 
     396    def getKey(self): 
     397        """ Returns the key of the item (non-translated name). 
    389398        The name of an item idientifies the kind of item it is: "Name", "Country", "Fixed Text"... 
    390399        """ 
    391         return self.__itemData['name'] 
     400        if "key" in self.__itemData: 
     401            return self.__itemData['key'] 
     402        else: 
     403            return self.__itemData['name'] 
    392404 
    393405    def getFixedText(self): 
  • indico/MaKaC/badgeDesignConf.py

    r8c5d7bf r550acf  
    101101            confDateInterval = adjusted_sDate.strftime("%d %B %Y") 
    102102        elif adjusted_sDate.strftime("%B%Y") == adjusted_eDate.strftime("%B%Y"): 
    103            confDateInterval = "%s-%s %s"%(adjusted_sDate.day, adjusted_eDate.day, adjusted_sDate.strftime("%B %Y")) 
     103            confDateInterval = "%s-%s %s"%(adjusted_sDate.day, adjusted_eDate.day, adjusted_sDate.strftime("%B %Y")) 
    104104        return confDateInterval 
    105105 
     
    133133    def __init__(self): 
    134134 
    135             self.items_actions = { _("Title") : Registrant.getTitle, 
    136                                _("Full Name") : Registrant.getFullName, 
    137                                _("Full Name (w/o title)") : RegistrantFullName2, 
    138                                _("Full Name B") : RegistrantFullName3, 
    139                                _("Full Name B (w/o title)") : RegistrantFullName4, 
    140                                _("Full Name C") : RegistrantFullName5, 
    141                                _("Full Name C (w/o title)") : RegistrantFullName6, 
    142                                _("First Name") : Registrant.getFirstName, 
    143                                _("Surname") : Registrant.getSurName, 
    144                                _("Position") : Registrant.getPosition, 
    145                                _("Institution") : Registrant.getInstitution, 
    146                                _("Country") : RegistrantCountry, 
    147                                _("City") : Registrant.getCity, 
    148                                _("Address") : Registrant.getAddress, 
    149                                _("Phone") : Registrant.getPhone, 
    150                                _("Fax") : Registrant.getFax, 
    151                                _("Email") : Registrant.getEmail, 
    152                                _("Personal homepage") : Registrant.getPersonalHomepage, 
    153                                _("Amount") : Registrant.getTotal, 
    154                                _("Conference Name") : Conference.getTitle, 
    155                                _("Conference Dates") : ConferenceDates, 
    156                                _("Fixed Text") : BadgeTemplateItem.getFixedText 
     135            self.items_actions = { "Title":               (_("Title"), Registrant.getTitle), 
     136                               "Full Name":               (_("Full Name"), Registrant.getFullName), 
     137                               "Full Name (w/o title)":   (_("Full Name (w/o title)"), RegistrantFullName2), 
     138                               "Full Name B":             (_("Full Name B"), RegistrantFullName3), 
     139                               "Full Name B (w/o title)": (_("Full Name B (w/o title)"), RegistrantFullName4), 
     140                               "Full Name C":             (_("Full Name C"), RegistrantFullName5), 
     141                               "Full Name C (w/o title)": (_("Full Name C (w/o title)"), RegistrantFullName6), 
     142                               "First Name":              (_("First Name"), Registrant.getFirstName), 
     143                               "Surname":                 (_("Surname"), Registrant.getSurName), 
     144                               "Position":                (_("Position"), Registrant.getPosition), 
     145                               "Institution":             (_("Institution"), Registrant.getInstitution), 
     146                               "Country":                 (_("Country"), RegistrantCountry), 
     147                               "City":                    (_("City"), Registrant.getCity), 
     148                               "Address":                 (_("Address"), Registrant.getAddress), 
     149                               "Phone":                   (_("Phone"), Registrant.getPhone), 
     150                               "Fax":                     (_("Fax"), Registrant.getFax), 
     151                               "Email":                   (_("Email"), Registrant.getEmail), 
     152                               "Personal homepage":       (_("Personal homepage"), Registrant.getPersonalHomepage), 
     153                               "Amount":                  (_("Amount"), Registrant.getTotal), 
     154                               "Conference Name":         (_("Conference Name"), Conference.getTitle), 
     155                               "Conference Dates":        (_("Conference Dates"), ConferenceDates), 
     156                               "Fixed Text":              (_("Fixed Text"), BadgeTemplateItem.getFixedText) 
    157157                            } 
    158158 
     
    160160            The groups are only used for the <select> box in the WConfModifBadgeDesign.tpl file. 
    161161            """ 
    162             self.groups = [( _("Registrant Data"), [ _("Title"), _("Full Name"), _("Full Name (w/o title)"), _("Full Name B"), _("Full Name B (w/o title)"), _("Full Name C"), _("Full Name C (w/o title)"), _("First Name"),  _("Surname"),  _("Position"), 
    163                                                      _("Institution"),  _("Country"),  _("City"), _("Address"), _("Phone"), _("Fax"), _("Email"), _("Personal homepage"), _("Amount")]), 
    164                       ( _("Conference Data"), [ _("Conference Name"),  _("Conference Dates")]), 
    165                       ( _("Fixed Elements"), [ _("Fixed Text")])] 
     162            self.groups = [( _("Registrant Data"), [ "Title", "Full Name", "Full Name (w/o title)", "Full Name B", "Full Name B (w/o title)", "Full Name C", "Full Name C (w/o title)", "First Name",  "Surname",  "Position", 
     163                                                     "Institution",  "Country",  "City", "Address", "Phone", "Fax", "Email", "Personal homepage", "Amount"]), 
     164                      ( _("Conference Data"), [ "Conference Name",  "Conference Dates"]), 
     165                      ( _("Fixed Elements"), [ "Fixed Text"])] 
  • indico/MaKaC/webinterface/pages/conferences.py

    re5c75c r550acf  
    1212812128        vars["loadingIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("loading"))) 
    1212912129        vars["templateId"]=self.__templateId 
     12130        from MaKaC.services.interface.rpc.json import encode as jsonEncode 
     12131        vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in BadgeDesignConfiguration().items_actions.iteritems()])) 
    1213012132 
    1213112133        cases = [] 
    12132         for itemName in BadgeDesignConfiguration().items_actions.keys(): 
     12134        badgeDesignConfiguration = BadgeDesignConfiguration() 
     12135        for itemKey in badgeDesignConfiguration.items_actions.keys(): 
    1213312136            case = [] 
    1213412137            case.append('case "') 
    12135             case.append(itemName) 
     12138            case.append(itemKey) 
    1213612139            case.append('":') 
    1213712140            case.append('\n') 
    1213812141            case.append('items[itemId] = new Item(itemId, "') 
    12139             case.append(itemName) 
     12142            case.append(itemKey) 
    1214012143            case.append('");') 
    1214112144            case.append('\n') 
     
    1214812151 
    1214912152        optgroups = [] 
    12150         for optgroupName, options in BadgeDesignConfiguration().groups: 
     12153        for optgroupName, options in badgeDesignConfiguration.groups: 
    1215112154            optgroup = [] 
    1215212155            optgroup.append('<optgroup label="') 
     
    1215512158            optgroup.append('\n') 
    1215612159            for optionName in options: 
    12157                 optgroup.append('<option>') 
    12158                 optgroup.append(optionName) 
     12160                optgroup.append('<option value="%s">'%optionName) 
     12161                optgroup.append(badgeDesignConfiguration.items_actions[optionName][0]) 
    1215912162                optgroup.append('</option>') 
    1216012163                optgroup.append('\n') 
     
    1248612489            vars["titleMessage"]= _("Editing poster template") 
    1248712490            vars["editingTemplate"]="true" 
    12488             templateDataString = simplejson.dumps(self.__conf.getPosterTemplateManager().getTemplateData(self.__templateId)) 
     12491            from MaKaC.services.interface.rpc.json import encode as jsonEncode 
     12492            templateDataString = jsonEncode(self.__conf.getPosterTemplateManager().getTemplateData(self.__templateId)) 
    1248912493            vars["templateData"]=quoteattr(templateDataString) 
    1249012494 
  • indico/MaKaC/webinterface/tpls/ConfModifBadgeDesign.tpl

    r626e2c r550acf  
    1414    // Number of pixels per cm 
    1515    var pixelsPerCm = 50; 
    16      
     16 
    1717    // Id of the background used 
    1818    var backgroundId = -1 
     
    3232    var lastSelectedDiv; 
    3333 
     34    // Translation dictionary from key to name in current language. 
     35    var translate = <%=translateName%>; 
     36 
    3437    // List of badge template items 
    3538    var items = []; 
    3639 
    3740    // Item class 
    38     function Item(itemId, name) { 
     41    function Item(itemId, key) { 
    3942      this.id = itemId; 
    40       this.name = name; 
     43      this.key = key; 
    4144      this.x = initialOffset; 
    4245      this.y = initialOffset; 
     
    6467              '" style="cursor:move; font-weight:' + (this.bold ? 'bold' : 'normal') + '; font-style:' + (this.italic ? 'italic' : 'normal') + 
    6568              '; text-align: ' + this.textAlign + ';"' + 
    66               '><tbody><tr><td><span style="color:' + this.color + '; font-family: ' + this.fontFamily + '; font-size:' + this.fontSize + ';">' +  
    67               (this.name == "Fixed Text" ? this.text : this.name) +  
     69              '><tbody><tr><td><span style="color:' + this.color + '; font-family: ' + this.fontFamily + '; font-size:' + this.fontSize + ';">' + 
     70              (this.key == "Fixed Text" ? this.text : translate[this.key]) + 
    6871              '</span></td></tr></tbody></table>'; 
    6972      } 
    70        
     73 
    7174    // Dimensions class 
    7275    function Dimensions(width, height) { 
     
    106109    //       -an inner HTML with its content 
    107110      itemId++; 
    108      
     111 
    109112      var newDiv = document.createElement('div'); 
    110113 
     
    152155 
    153156        snap: ($F('snap checkbox') == "on") ? mySnap : false 
    154       });  
     157      }); 
    155158 
    156159      // We store the initial position as a good position which to return to 
    157160      newDiv.lastGoodPositionLeft = 0; 
    158161      newDiv.lastGoodPositionTop = 0; 
    159        
     162 
    160163      return newDiv; 
    161164        } 
     
    174177        markSelected(newDiv); 
    175178      } 
    176        
     179 
    177180      initialOffset += 10 
    178181 
     
    211214 
    212215      // Change the text that says which item is selected 
    213       $E('selection text').dom.innerHTML = items[newSelectedDiv.id].name; 
     216      $E('selection text').dom.innerHTML = translate[items[newSelectedDiv.id].key]; 
    214217 
    215218      // TODO: add check to see if there's a table inside and not an image 
     
    233236      $E('color selector').dom.selectedIndex = newSelectedItem.colorIndex; 
    234237      $E('width field').dom.value = newSelectedItem.width / pixelsPerCm; 
    235       if (newSelectedItem.name == "Fixed Text") { 
     238      if (newSelectedItem.key == "Fixed Text") { 
    236239        $E('fixed text field').dom.value = newSelectedItem.text 
    237240      } else { 
     
    277280 
    278281    } 
    279      
     282 
    280283    // This function displays all the items in the 'items' array on the screen 
    281284    // If there are already some items being displayed, it does not erase them 
     
    432435      } 
    433436    } 
    434      
     437 
    435438    function changeText() { 
    436439      if(lastSelectedDiv) { 
     
    454457      document.hiddenform.submit() 
    455458    } 
    456      
     459 
    457460    function sending() { 
    458461      Element.show('loadingIcon'); 
    459462    } 
    460      
     463 
    461464    firstLoad = true; 
    462      
     465 
    463466    function sent() { 
    464467      if (firstLoad) { 
     
    486489      Element.hide('loadingIcon'); 
    487490    } 
    488      
     491 
    489492    function displayBackground(backgroundURL) { 
    490493        var newBackground = document.createElement('img'); 
     
    500503        var template = $E("templateDiv").dom; 
    501504        template.appendChild(newBackground); 
    502      
    503     } 
    504      
     505 
     506    } 
     507 
    505508    function removeBackground() { 
    506509      if (backgroundId != -1) { 
     
    511514 
    512515  </script> 
    513    
     516 
    514517<!-- CONTEXT HELP DIVS --> 
    515518<div id="tooltipPool" style="display: none"> 
    516     <!-- Where is key? -->  
     519    <!-- Where is key? --> 
    517520    <div id="features" class="tip"> 
    518521        <b>FullName can have four different formats:</b><br> 
     
    523526    </div> 
    524527</div> 
    525 <!-- END OF CONTEXT HELP DIVS -->   
    526    
    527    
     528<!-- END OF CONTEXT HELP DIVS --> 
     529 
     530 
    528531<iframe id="uploadTarget" name="uploadTarget" src="" style="width:0px;height:0px;border:0" onload="sent()"></iframe> 
    529532 
     
    593596          <input name="Delete Template Element Button" class="btn" value="<%= _("Remove")%>" type="button" onclick="removeElement()"> 
    594597 
    595           <br/><br/>  
     598          <br/><br/> 
    596599 
    597600          <select name="Template Elements List" id="elementList"> 
     
    813816    </tbody> 
    814817  </table> 
    815    
     818 
    816819  <form name="hiddenform" action="<%=saveTemplateURL%>" method="POST"> 
    817820        <input name="templateId" value="<%=templateId%>" type="hidden"> 
    818821        <input id="templateData" name="templateData" type="hidden"> 
    819822  </form> 
    820    
     823 
    821824<!-- 
    822825  <table id='test' width="200" height="200" border="1" onclick="alert(Element.getDimensions(this).width);this.width = parseInt(this.width) + 10; return false"> 
     
    826829 
    827830  <script type="text/javascript"> 
    828    
     831 
    829832    // We load the template if we are editing a template 
    830833    if (%(editingTemplate)s) { 
     
    842845       templateDimensions = new Dimensions(425,270); //put here the initial dimensions of templateDiv. This is CERN default of 85mm x 54mm 
    843846    } 
    844          
     847 
    845848    previousTemplateDimensions = new Dimensions(0,0) 
    846      
     849 
    847850    $E('badge width').dom.value = templateDimensions.width / pixelsPerCm; 
    848851    $E('badge height').dom.value = templateDimensions.height / pixelsPerCm; 
    849      
     852 
    850853    // This function initialises the rulers 
    851854    updateRulers(); 
    852      
     855 
    853856    // This function displays the items, if any have been loaded, on the screen 
    854857    displayItems() 
    855      
     858 
    856859    if (<%=editingTemplate%> && <%=hasBackground%>) { 
    857860       backgroundId = <%=backgroundId%> 
Note: See TracChangeset for help on using the changeset viewer.