mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Translate language and country names separately in the fetch news dialog
This commit is contained in:
parent
aaeeb51573
commit
af5bd7ee60
@ -377,8 +377,6 @@ _extra_lang_codes = {
|
||||
'de_AT' : _('German (Austria)'),
|
||||
'fr_BE' : _('French (Belgium)'),
|
||||
'fr_CA' : _('French (Canadian)'),
|
||||
'nl' : _('Dutch (Netherlands)'),
|
||||
'nl_BE' : _('Dutch (Belgium)'),
|
||||
'und' : _('Unknown')
|
||||
}
|
||||
|
||||
@ -411,6 +409,7 @@ if False:
|
||||
_('Step &down')
|
||||
_('Close without Saving')
|
||||
_('Close Tab')
|
||||
_('Ukraine')
|
||||
|
||||
_lcase_map = {}
|
||||
for k in _extra_lang_codes:
|
||||
@ -478,7 +477,10 @@ def countrycode_to_name(cc, localize=True):
|
||||
try:
|
||||
name = iso3166['names'][q]
|
||||
except Exception:
|
||||
return cc
|
||||
if q == 'UK':
|
||||
name = 'Ukraine'
|
||||
else:
|
||||
return cc
|
||||
translate = _ if localize else lambda x: x
|
||||
try:
|
||||
return translate(name)
|
||||
|
@ -11,7 +11,7 @@ from qt.core import (
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.utils.icu import primary_sort_key
|
||||
from calibre.utils.localization import _, get_language
|
||||
from calibre.utils.localization import _, get_language, countrycode_to_name
|
||||
from calibre.utils.resources import get_path as P
|
||||
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
||||
from calibre.web.feeds.recipes.collection import (
|
||||
@ -60,18 +60,28 @@ class NewsTreeItem:
|
||||
child.parent = None
|
||||
|
||||
|
||||
def parse_lang_code(x: str) -> str:
|
||||
lang, sep, country = x.partition('_')
|
||||
country = country.upper()
|
||||
ans = get_language(lang)
|
||||
if country:
|
||||
ans = _('{language} ({country})').format(language=ans, country=countrycode_to_name(country))
|
||||
return ans
|
||||
|
||||
|
||||
@total_ordering
|
||||
class NewsCategory(NewsTreeItem):
|
||||
|
||||
def __init__(self, category, builtin, custom, scheduler_config, parent):
|
||||
NewsTreeItem.__init__(self, builtin, custom, scheduler_config, parent)
|
||||
self.category = category
|
||||
self.cdata = get_language(self.category)
|
||||
self.category = self.cdata = category
|
||||
self.cdata = self.category
|
||||
if self.category == _('Scheduled'):
|
||||
self.sortq = 0, ''
|
||||
elif self.category == _('Custom'):
|
||||
self.sortq = 1, ''
|
||||
else:
|
||||
self.cdata = parse_lang_code(self.cdata)
|
||||
self.sortq = 2, self.cdata
|
||||
self.bold_font = QFont()
|
||||
self.bold_font.setBold(True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user