Permalink
Browse files

Little changes to make locking translatable:

- use named format in string when there are more than one
- do not concatenate strings in javascript's gettext
  • Loading branch information...
yohanboniface committed Apr 5, 2012
1 parent 406c6e6 commit dea325ff05f333102c969027afa5578a18a74658
Showing with 16 additions and 31 deletions.
  1. +8 −10 locking/admin.py
  2. +1 −1 locking/forms.py
  3. +7 −20 locking/static/locking/js/admin.locking.js
View
@@ -1,4 +1,4 @@
-# coding=utf8
+# -*- coding: utf-8 -*-
from django.utils import simplejson
from datetime import datetime
from django.conf.urls.defaults import patterns, url
@@ -126,23 +126,21 @@ def get_object(self, request, object_id):
return obj
def lock(self, obj):
+ message = ''
if obj.is_locked:
seconds_remaining = obj.lock_seconds_remaining
minutes_remaining = seconds_remaining/60
- locked_until = _("Still locked for %s minutes by %s") \
- % (minutes_remaining, obj.locked_by)
if self.request.user == obj.locked_by:
locked_until_self = _("You have a lock on this article for %s more minutes.") \
% (minutes_remaining)
- return '<img src="%slocking/img/page_edit.png" title="%s" />' \
+ message = '<img src="%slocking/img/page_edit.png" title="%s" />' \
% (settings.MEDIA_URL, locked_until_self)
else:
- locked_until = _("Still locked for %s minutes by %s") \
- % (minutes_remaining, obj.locked_by)
- return '<img src="%slocking/img/lock.png" title="%s" />' \
+ locked_until = _("Still locked for %(minutes)s minutes by %(user)s") \
+ % {"minutes": minutes_remaining, "user": obj.locked_by}
+ message = '<img src="%slocking/img/lock.png" title="%s" />' \
% (settings.MEDIA_URL, locked_until)
- else:
- return ''
+ return message
lock.allow_tags = True
- list_display = ('__str__', 'lock')
+ list_display = ('__str__', 'lock')
View
@@ -68,4 +68,4 @@ def clean(self):
self._locking_error_when_saving = 'was_already_locked'
raise forms.ValidationError('Locking problem !')
- return self.cleaned_data
+ return self.cleaned_data
@@ -82,36 +82,23 @@ locking.admin = function() {
};
// Texts.
var text = {
- warn: gettext('Your lock on this page expires in less than %s' +
- ' minutes. Press save or <a href=".">reload the page</a>.'),
- is_locked: gettext('This page is locked by <em>%(for_user)s' +
- '</em> and editing is disabled. ' +
- 'Ask him/her to release the lock and then try <a href=".">reloading the page</a>.'),
+ warn: gettext('Your lock on this page expires in less than %s minutes. Press save or <a href=".">reload the page</a>.'),
+ is_locked: gettext('This page is locked by <em>%(for_user)s</em> and editing is disabled. Ask him/her to release the lock and then try <a href=".">reloading the page</a>.'),
editing: gettext('(you are in edit mode)'
),
- has_expired: gettext('Your lock on this page is expired!' +
- ' Saving your changes might not be possible, ' +
- ' but you are welcome to try.'
+ has_expired: gettext('Your lock on this page is expired! Saving your changes might not be possible, but you are welcome to try.'
),
- was_already_locked: gettext('It appears that you were already editing' +
- ' this page (maybe in another tab or window ?). If you think this is' +
- ' a mistake, you can choose to <a href="#force-release" class="force-release">force-release the lock</a>.'
+ was_already_locked: gettext('It appears that you were already editing this page (maybe in another tab or window ?). If you think this is a mistake, you can choose to <a href="#force-release" class="force-release">force-release the lock</a>.'
),
prompt_to_save: 'Do you wish to save the page?',
};
var errors_when_saving = {
- was_already_locked: gettext('It appears that you were already editing' +
- ' this page (maybe in another tab or window ?). If you think this is' +
- ' a mistake, you can choose to <a href="#force-save" class="force-save">force saving</a>.'
+ was_already_locked: gettext('It appears that you were already editing this page (maybe in another tab or window ?). If you think this is a mistake, you can choose to <a href="#force-save" class="force-save">force saving</a>.'
),
- not_locked_and_modified: gettext('It appears that object was modified since you' +
- ' extracted it. You can choose to <a href="#force-save" class="force-save">force saving</a>' +
- ' but you may override some changes...'
+ not_locked_and_modified: gettext('It appears that object was modified since you extracted it. You can choose to <a href="#force-save" class="force-save">force saving</a> but you may override some changes...'
),
- locked_by_someone_else: gettext('%s is editing this object !' +
- ' Before saving, you need to ask him/her to release the lock. Note that if' +
- ' he/she saves, conflicts may happen.'
+ locked_by_someone_else: gettext('%s is editing this object ! Before saving, you need to ask him/her to release the lock. Note that if he/she saves, conflicts may happen.'
),
}

0 comments on commit dea325f

Please sign in to comment.