[GTK] Fixup translation strings

- Use named placeholders to allow translators to change text order.
- Refactor fpcnt to use format() and markup strings properly.

- Remove gettext.js creatation from generate_pot script since this step
  is now always done at build-time.
This commit is contained in:
Calum Lind 2018-10-21 10:59:28 +01:00
parent d85f665091
commit 3645feb486
3 changed files with 10 additions and 10 deletions

View File

@ -313,7 +313,9 @@ class MainWindow(component.Component):
status['payload_upload_rate'], precision=0, shortform=True status['payload_upload_rate'], precision=0, shortform=True
) )
self.window.set_title( self.window.set_title(
_('D: %s U: %s - Deluge' % (download_rate, upload_rate)) _('D: {download_rate} U: {upload_rate} - Deluge').format(
download_rate=download_rate, upload_rate=upload_rate
)
) )
if self.config['show_rate_in_title']: if self.config['show_rate_in_title']:

View File

@ -22,12 +22,14 @@ def fratio(value):
def fpcnt(value, state, message): def fpcnt(value, state, message):
textstr = _(state) state_i18n = _(state)
if state not in ('Error', 'Seeding') and value < 100: if state not in ('Error', 'Seeding') and value < 100:
textstr = ('%s %.2f' % (textstr, value)).rstrip('0').rstrip('.') + '%' percent = '{:.2f}'.format(value).rstrip('0').rstrip('.')
return _('{state} {percent}%').format(state=state_i18n, percent=percent)
elif state == 'Error': elif state == 'Error':
textstr = _('%s: %s') % (textstr, message) return _('{state}: {err_msg}').format(state=state_i18n, err_msg=message)
return textstr else:
return state_i18n
def fspeed_max(value, max_value=-1): def fspeed_max(value, max_value=-1):

View File

@ -18,7 +18,6 @@ import re
from datetime import datetime from datetime import datetime
from subprocess import call from subprocess import call
from gen_web_gettext import create_gettext_js
from version import get_version from version import get_version
# Paths to exclude # Paths to exclude
@ -108,7 +107,4 @@ for filepath in to_translate:
if filepath.endswith('.h'): if filepath.endswith('.h'):
os.remove(filepath) os.remove(filepath)
# Update web js gettext print('Created %s' % POT_FILEPATH)
create_gettext_js(WEBUI_JS_DIR)
print('Created %s and updated gettext.js' % POT_FILEPATH)