Ignore:
Timestamp:
28 Feb 2012, 20:52:18 (13 years ago)
Author:
Henrik Bettermann
Message:

Internationalize accessodes package.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.py

    r7649 r7719  
    2727    AdminTask, AddActionButton, SearchActionButton, BatchOpButton, ManageLink)
    2828from waeup.sirp.interfaces import ISIRPObject
    29 
     29from waeup.sirp.interfaces import MessageFactory as _
    3030from waeup.sirp.accesscodes.interfaces import (
    3131    IAccessCodeBatchContainer, IAccessCodeBatch,
     
    4141    grok.template('batchcontainer')
    4242    grok.require('waeup.manageACBatches')
    43 
    44     label = 'Access Code Batches'
     43    archive_button = _('Archive')
     44    delete_button = _('Archive and delete')
     45
     46    label = _('Access Code Batches')
    4547    pnav = 0
    4648
     
    4951            return
    5052        if not batches:
    51             self.flash('No batch selected.')
     53            self.flash(_('No batch selected.'))
    5254            return
    5355        if isinstance(batches, basestring):
     
    5658            batch = self.context[name]
    5759            csv_file = batch.archive()
    58             self.flash('Archived %s (%s)' % (name, csv_file))
     60            self.flash(_('Archived ${a} (${b})',
     61                mapping = {'a':name, 'b':csv_file}))
    5962            if delete is None:
    6063                continue
    6164            del self.context[name]
    62             self.flash('Deleted batch %s' % name)
     65            self.flash(_('Deleted batch ${a}', mapping = {'a':name}))
    6366
    6467class AddBatchPage(SIRPAddFormPage):
     
    6770    grok.require('waeup.manageACBatches')
    6871
    69     label = 'Create Access Code Batch'
     72    label = _('Create Access Code Batch')
    7073    pnav = 0
    7174
     
    7376        'prefix', 'entry_num', 'cost')
    7477
    75     @action('Create batch', style='primary')
     78    @action(_('Create batch'), style='primary')
    7679    def createBatch(self, **data):
    7780        creator = self.request.principal.id
     
    8588        self.redirect(self.url(self.context))
    8689
    87     @action('Cancel', validator=NullValidator)
     90    @action(_('Cancel'), validator=NullValidator)
    8891    def cancel(self, *args, **kw):
    89         self.flash('Batch creation cancelled.')
     92        self.flash(_('Batch creation cancelled.'))
    9093        self.redirect(self.url(self.context))
    9194
     
    97100    grok.template('reimportbatchpage')
    98101    grok.require('waeup.manageACBatches')
    99 
    100     label = 'Reimport Access Code Batches'
     102    reimport_button = _('Reimport')
     103    cancel_button = _('Cancel')
     104
     105    label = _('Reimport Access Code Batches')
    101106    pnav = 0
    102107
    103108    def update(self, filenames=None, reimport=None, cancel=None):
    104109        if cancel is not None:
    105             self.flash('Reimport cancelled.')
     110            self.flash(_('Reimport cancelled.'))
    106111            self.redirect(self.url(self.context))
    107112            return
     
    109114            return
    110115        if not filenames:
    111             self.flash('No file chosen. Action cancelled.')
     116            self.flash(_('No file chosen. Action cancelled.'))
    112117            self.redirect(self.url(self.context))
    113118            return
     
    119124                self.context.reimport(filename, userid)
    120125            except KeyError:
    121                 self.flash('This batch already exists: %s' % filename)
     126                self.flash(_('This batch already exists: ${a}',
     127                    mapping = {'a':filename}))
    122128                continue
    123             self.flash('Successfully reimported: %s' % filename)
     129            self.flash(_('Successfully reimported: ${a}',
     130                mapping = {'a':filename}))
    124131        self.redirect(self.url(self.context))
    125132
     
    130137    grok.require('waeup.manageACBatches')
    131138    pnav = 0
    132     label = 'Search and Manage Access Codes'
     139    label = _('Search and Manage Access Codes')
     140    search_button = _('Search')
     141    disable_button = _('Disable ACs')
     142    enable_button = _('Enable ACs')
    133143
    134144    def update(self, *args, **kw):
     
    154164            if 'disable' in form:
    155165                try:
    156                     comment = u"AC disabled"
     166                    comment = _(u"AC disabled")
    157167                    self.context.disable(entry, comment)
    158                     self.flash('%s disabled.' % entry)
     168                    self.flash(_('${a} disabled.', mapping = {'a':entry}))
    159169                except InvalidTransitionError:
    160                     self.flash('%s: Disable transition not allowed.' % entry)
     170                    self.flash(_('${a}: Disable transition not allowed.',
     171                        mapping = {'a':entry}))
    161172            elif 'enable' in form:
    162173                try:
    163                     comment = u"AC re-enabled"
     174                    comment = _(u"AC re-enabled")
    164175                    self.context.enable(entry, comment)
    165                     self.flash('%s (re-)enabled.' % entry)
     176                    self.flash(_('${a} (re-)enabled.', mapping = {'a':entry}))
    166177                except InvalidTransitionError:
    167                     self.flash('%s: Re-enable transition not allowed.' % entry)
     178                    self.flash(_('${a}: Re-enable transition not allowed.', mapping = {'a':entry}))
    168179        self.hitlist = search(query=self.searchterm,
    169180            searchtype=self.searchtype, view=self)
     
    175186    grok.require('waeup.manageACBatches')
    176187    grok.context(IAccessCodeBatchContainer)
    177     title = u'Access Code Batches'
     188    title = _(u'Access Code Batches')
    178189    parent_viewname = 'administration'
    179190
     
    195206    grok.template('admintaskacbatches')
    196207
    197     link_title = 'Access Code Batches'
     208    link_title = _('Access Code Batches')
    198209    target_viewname = 'accesscodes'
    199210
     
    204215    grok.view(BatchContainerPage)
    205216    grok.require('waeup.manageACBatches')
    206     text = 'Add Access Code Batch'
     217    text = _('Add Access Code Batch')
    207218
    208219class ReimportBatchButton(BatchOpButton):
     
    213224    grok.require('waeup.manageACBatches')
    214225    target = 'reimport'
    215     text = 'Reimport Access Code Batch'
     226    text = _('Reimport Access Code Batch')
    216227
    217228class SearchAccessCodeButton(SearchActionButton):
     
    221232    grok.view(BatchContainerPage)
    222233    grok.require('waeup.manageACBatches')
    223     text = 'Search Access Codes'
     234    text = _('Search Access Codes')
    224235
    225236class ManageAccessCodes(ManageLink):
     
    230241
    231242    link = u'accesscodes'
    232     text = u'Access Codes'
     243    text = _(u'Access Codes')
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.txt

    r7631 r7719  
    175175    >>> ctrl = browser.getControl(name='batches')
    176176    >>> ctrl.getControl(value='BLA-1').selected = True
    177     >>> browser.getControl('Archive and Delete').click()
     177    >>> browser.getControl('Archive and delete').click()
    178178    >>> print browser.contents
    179179    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     
    284284      <td>APP-1-...</td>
    285285      <td>initialized</td>
    286       <td>... - AC initialized by Manager</td>
     286      <td>... - initialized by Manager</td>
    287287    ...
    288288
     
    303303      <td>APP-1-...</td>
    304304      <td>initialized</td>
    305       <td>... - AC initialized by Manager</td>
     305      <td>... - initialized by Manager</td>
    306306    ...
    307307
    308308And we can search for text in history messages of access
    309 codes. Looking for the string ``AC initialized`` we get nearly all
     309codes. Looking for the string ``initialized`` we get nearly all
    310310entries:
    311311
     
    313313    >>> ctrl = browser.getControl(name='searchtype')
    314314    >>> ctrl.getControl(value='history').selected = True
    315     >>> browser.getControl(name='searchterm').value = 'AC initialized'
     315    >>> browser.getControl(name='searchterm').value = 'initialized'
    316316    >>> browser.getControl('Search').click()
    317317    >>> print browser.contents
     
    322322      <td>APP-1-<10-DIGITS></td>
    323323      <td>initialized</td>
    324       <td>... - AC initialized by Manager</td>
     324      <td>... - initialized by Manager</td>
    325325    ...
    326326
     
    334334    >>> ctrl = browser.getControl(name='searchtype')
    335335    >>> ctrl.getControl(value='history').selected = True
    336     >>> browser.getControl(name='searchterm').value = 'AC initialized'
     336    >>> browser.getControl(name='searchterm').value = 'initialized'
    337337    >>> browser.getControl('Search').click()
    338338
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/admintaskacbatches.pt

    r7459 r7719  
    22<a href=""
    33   tal:attributes="href viewlet/link_target"
    4    tal:content="viewlet/link_title">Manage</a>
     4   tal:content="viewlet/link_title">MANAGE</a>
    55</p>
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/batchcontainer.pt

    r7467 r7719  
    1 <form method="POST">
    2   <p>
     1<form i18n:domain="waeup.sirp" method="POST">
     2  <p i18n:translate="">
    33    The following batches are available:
    44  </p>
    5 
    65  <table>
    76    <thead>
    87      <tr>
    98        <th>&nbsp;</th>
    10   <th>Prefix</th><th>Entries/(invalidated)</th><th>Cost</th>
    11   <th>Created</th><th>Creator</th>
     9        <th i18n:translate="">Prefix</th>
     10        <th i18n:translate="">Entries/(invalidated)</th>
     11        <th i18n:translate="">Cost</th>
     12        <th i18n:translate="">Date of Creation</th>
     13        <th i18n:translate="">Creator</th>
    1214      </tr>
    1315    </thead>
     
    3234      2011-11-22 18:04:55
    3335  </td>
    34   <td tal:content="batch/creator">some user</td>
     36  <td tal:content="batch/creator">SOMEUSER</td>
    3537      </tr>
    3638      <tr tal:condition="not: context/values">
    37   <td colspan="5"><b>No batches yet</b></td>
     39      <td colspan="5"><b i18n:translate="">No batches yet</b></td>
    3840      </tr>
    3941    </tbody>
    4042  </table>
    41   <input type="submit" class="btn" name="archive" value="Archive" />
    42   <input type="submit" class="btn" name="delete" value="Archive and Delete" />
     43  <input type="submit" class="btn" name="archive"
     44      tal:attributes="value view/archive_button" />
     45  <input type="submit" class="btn" name="delete"
     46       tal:attributes="value view/delete_button" />
    4347</form>
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/reimportbatchpage.pt

    r7467 r7719  
    1 <p> Please select the files to reimport. Please note, that batches with  same name have to be deleted before.
     1<p i18n:domain="waeup.sirp">
     2Please select the files to reimport. Please note, that batches with
     3same name have to be deleted before.
    24</p>
    3 <form method="POST">
     5<form method="POST" i18n:domain="waeup.sirp">
    46  <table>
    57    <thead>
     
    79        <th>&nbsp;
    810        </th>
    9         <th>File
     11        <th i18n:translate="">File
    1012        </th>
    1113      </tr>
    1214    </thead>
    1315    <tbody>
    14       <tr tal:repeat="filename context/getImportFiles"  tal:attributes="class python: repeat['filename'].odd() and 'even' or 'odd'"> <td>
    15           <input type="checkbox" name="filenames" value="filename"  tal:attributes="value filename" /> </td>
    16         <td tal:content="filename">file.name</td>
     16      <tr tal:repeat="filename context/getImportFiles"
     17          tal:attributes="class python: repeat['filename'].odd() and 'even' or 'odd'"> <td>
     18          <input type="checkbox" name="filenames" value="filename"
     19              tal:attributes="value filename" /> </td>
     20        <td tal:content="filename">FILENAME</td>
    1721      </tr>
    1822      <tr tal:condition="python: len(list(context.getImportFiles())) == 0">
    19         <td colspan="5"><b>No import batches available</b></td>
     23        <td colspan="5"><b i18n:translate="">No import batches available</b></td>
    2024      </tr>
    2125    </tbody>
    2226  </table>
    23   <input type="submit" class="btn primary" name="reimport" value="Reimport" />
    24   <input type="submit" class="btn" name="cancel" value="Cancel" />
     27  <input type="submit" class="btn primary" name="reimport"
     28      tal:attributes="value view/reimport_button" />
     29  <input type="submit" class="btn" name="cancel"
     30      tal:attributes="value view/cancel_button" />
    2531</form>
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/searchpage.pt

    r7459 r7719  
    1 <form method="POST">
    2 
     1<form method="POST" i18n:domain="waeup.sirp">
    32<br />
    4 
    5   <input type="submit" class="btn primary" name="search" value="Search" />
    6   for access codes
    7 
     3  <input type="submit" class="btn primary" name="search"
     4      tal:attributes="value view/search_button" />
     5  <span i18n:translate="">for access codes</span>
    86  <select name="searchtype">
    9     <option value="code">with PIN</option>
    10     <option value="batch_serial">with serial</option>
    11     <option value="history">with message term</option>
     7    <option i18n:translate="" value="code">with PIN</option>
     8    <option i18n:translate="" value="batch_serial">with serial</option>
     9    <option i18n:translate="" value="history">with message term</option>
    1210  </select>
    13 
    1411  <input type="text" name="searchterm" />
    15 
    1612  <p>&nbsp;</p>
    1713  <div tal:condition="view/hitlist">
     
    2521      <tr>
    2622        <th>&nbsp;</th>
    27         <th width="50px">Serial</th>
    28         <th>AC</th>
    29         <th>State</th>
    30         <th>Owner</th>
    31         <th>History</th>
     23        <th width="50px" i18n:translate="">Serial</th>
     24        <th i18n:translate="">AC</th>
     25        <th i18n:translate="">State</th>
     26        <th i18n:translate="">Owner</th>
     27        <th i18n:translate="">History</th>
    3228      </tr>
    3329      </thead>
     
    4743    </table>
    4844    <div>
    49       <input type="submit" class="btn" name="disable" value="Disable ACs" />
    50       <input type="submit" class="btn" name="enable" value="Enable ACs" />
     45      <input type="submit" class="btn" name="disable"
     46          tal:attributes="value view/disable_button" />
     47      <input type="submit" class="btn" name="enable"
     48          tal:attributes="value view/enable_button" />
    5149    </div>
    5250
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/interfaces.py

    r7321 r7719  
    2121from zope.interface import Interface
    2222from waeup.sirp.interfaces import ISIRPObject
     23from waeup.sirp.interfaces import MessageFactory as _
    2324
    2425class IAccessCode(ISIRPObject):
     
    2627    """
    2728    batch_serial = schema.Int(
    28         title = u'Serial number inside batch',
     29        title = _(u'Serial number inside batch'),
    2930        )
    3031    batch_prefix = schema.TextLine(
    31         title = u'Prefix inside batch',
     32        title = _(u'Prefix inside batch'),
    3233        )
    3334    batch_num = schema.Int(
    34         title = u'Batch number',
     35        title = _(u'Batch number'),
    3536        )
    3637    random_num = schema.TextLine(
    37         title = u'Random part of access code.',
     38        title = _(u'Random part of access code.'),
    3839        )
    3940    cost = schema.Float(
    40         title = u'Cost of access code',
     41        title = _(u'Cost of access code'),
    4142        default = 0.0, min = 0.0,
    4243        )
    4344    state = schema.TextLine(
    44         title = u'Workflow state',
     45        title = _(u'Workflow state'),
    4546        )
    4647    representation = schema.TextLine(
    47         title = u'Complete title of access code',
     48        title = _(u'Complete title of access code'),
    4849        )
    4950    owner = schema.TextLine(
    50         title = u'Purchaser',
     51        title = _(u'Purchaser'),
    5152        )
    5253    history = schema.Text(
    53         title = u'The history of access code as lines',
     54        title = _(u'The history of access code as lines'),
    5455        default = u'',
    5556        readonly = True,
     
    6061    """
    6162    creation_date = schema.Date(
    62         title = u'Creation date',
     63        title = _(u'Creation date'),
    6364        )
    6465    creator = schema.TextLine(
    65         title = u'Batch creator',
     66        title = _(u'Batch creator'),
    6667        )
    6768    prefix = schema.TextLine(
    68         title = u'Batch prefix',
     69        title = _(u'Batch prefix'),
    6970        )
    7071    num = schema.Int(
    71         title = u'Batch number (1-3 digits)',
     72        title = _(u'Batch number (1-3 digits)'),
    7273        min = 0, max = 999,
    7374        )
    7475    entry_num = schema.Int(
    75         title = u'Number of access codes',
     76        title = _(u'Number of access codes'),
    7677        default = 1000, min = 0,
    7778        )
    7879    cost = schema.Float(
    79         title = u'Cost of access code',
     80        title = _(u'Cost of access code'),
    8081        default = 0.0, min = 0.0,
    8182        )
    8283    disabled_num = schema.Int(
    83         title = u'Number of disabled access codes inside the batch',
     84        title = _(u'Number of disabled access codes inside the batch'),
    8485        default = 0,
    8586        readonly = True,
    8687        )
    8788    used_num = schema.Int(
    88         title = u'Number of used access codes inside the batch',
     89        title = _(u'Number of used access codes inside the batch'),
    8990        default = 0,
    9091        readonly = True,
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscode.py

    r7321 r7719  
    188188        history = IObjectHistory(self.ac1)
    189189        msgs = history.messages
    190         assert msgs[-1].endswith('AC used by system')
     190        assert msgs[-1].endswith('used by system')
    191191
    192192class AccessCodeTests(FunctionalTestCase):
     
    232232        # Access codes have a history.
    233233        match = re.match(
    234             '^....-..-.. ..:..:.. - AC initialized by system',
     234            '^....-..-.. ..:..:.. - initialized by system',
    235235            self.ac1.history)
    236236        assert match is not None
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/workflow.py

    r7689 r7719  
    2020"""
    2121import grok
     22from zope.i18n import translate
     23from zope.component import getUtility
    2224from datetime import datetime
    2325from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
    2426from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent
    2527from waeup.sirp.accesscodes.interfaces import IAccessCode
    26 from waeup.sirp.interfaces import IObjectHistory, ISIRPWorkflowInfo
     28from waeup.sirp.interfaces import IObjectHistory, ISIRPWorkflowInfo, ISIRPUtils
    2729from waeup.sirp.interfaces import MessageFactory as _
    2830from waeup.sirp.workflow import SIRPWorkflow, SIRPWorkflowInfo
     
    131133def handle_accesscode_transition_event(obj, event):
    132134    # append message to history
     135    portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE
    133136    if event.comment is not None:
    134         msg = '%s' % event.comment
     137        msg = event.comment
    135138    else:
    136         msg = 'AC %s' % event.destination
    137 
     139        msg = ac_states_dict[event.destination]
    138140    history = IObjectHistory(obj)
    139141    history.addMessage(msg)
Note: See TracChangeset for help on using the changeset viewer.