Use gettext for some strings

This commit is contained in:
Yen Chi Hsuan 2015-11-30 00:57:33 +08:00
parent 0712751165
commit e88797e463
6 changed files with 22 additions and 14 deletions

View File

@ -51,6 +51,7 @@ from .utils import (
ExtractorError,
format_bytes,
formatSeconds,
g,
locked_file,
make_HTTPS_handler,
MaxDownloadsReached,
@ -1545,7 +1546,7 @@ class YoutubeDL(object):
for ph in self._progress_hooks:
fd.add_progress_hook(ph)
if self.params.get('verbose'):
self.to_stdout('[debug] Invoking downloader on %r' % info.get('url'))
self.to_stdout(g('[debug] Invoking downloader on %r') % info.get('url'))
return fd.download(name, info)
if info_dict.get('requested_formats') is not None:
@ -1589,8 +1590,8 @@ class YoutubeDL(object):
filename = '%s.%s' % (filename_wo_ext, info_dict['ext'])
if os.path.exists(encodeFilename(filename)):
self.to_screen(
'[download] %s has already been downloaded and '
'merged' % filename)
g('[download] %s has already been downloaded and '
'merged') % filename)
else:
for f in requested_formats:
new_info = dict(info_dict)
@ -1723,7 +1724,7 @@ class YoutubeDL(object):
self.report_error(e.msg)
if files_to_delete and not self.params.get('keepvideo', False):
for old_filename in files_to_delete:
self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename)
self.to_screen(g('Deleting original file %s (pass -k to keep)') % old_filename)
try:
os.remove(encodeFilename(old_filename))
except (IOError, OSError):

View File

@ -10,6 +10,7 @@ from ..utils import (
encodeFilename,
decodeArgument,
format_bytes,
g,
timeconvert,
)
@ -211,10 +212,10 @@ class FileDownloader(object):
def report_destination(self, filename):
"""Report destination filename."""
self.to_screen('[download] Destination: ' + filename)
self.to_screen(g('[download] Destination: %s') % filename)
def _report_progress_status(self, msg, is_last_line=False):
fullmsg = '[download] ' + msg
fullmsg = g('[download] ') + msg
if self.params.get('progress_with_newline', False):
self.to_screen(fullmsg)
else:

View File

@ -33,6 +33,7 @@ from ..utils import (
ExtractorError,
fix_xml_ampersands,
float_or_none,
g,
int_or_none,
RegexNotFoundError,
sanitize_filename,
@ -503,7 +504,7 @@ class InfoExtractor(object):
def report_download_webpage(self, video_id):
"""Report webpage download."""
self.to_screen('%s: Downloading webpage' % video_id)
self.to_screen(g('%s: Downloading webpage') % video_id)
def report_age_confirmation(self):
"""Report attempt to confirm age."""

View File

@ -3,7 +3,10 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import ExtractorError
from ..utils import (
ExtractorError,
g,
)
class TestURLIE(InfoExtractor):
@ -59,7 +62,7 @@ class TestURLIE(InfoExtractor):
(num, len(testcases))),
expected=True)
self.to_screen('Test URL: %s' % tc['url'])
self.to_screen(g('Test URL: %s') % tc['url'])
return {
'_type': 'url',

View File

@ -42,6 +42,7 @@ from ..utils import (
unsmuggle_url,
uppercase_escape,
ISO3166Utils,
g,
)
@ -743,11 +744,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
def report_video_info_webpage_download(self, video_id):
"""Report attempt to download video info webpage."""
self.to_screen('%s: Downloading video info webpage' % video_id)
self.to_screen(g('%s: Downloading video info webpage') % video_id)
def report_information_extraction(self, video_id):
"""Report attempt to extract video information."""
self.to_screen('%s: Extracting video information' % video_id)
self.to_screen(g('%s: Extracting video information') % video_id)
def report_unavailable_format(self, video_id, format):
"""Report extracted video URL."""
@ -1024,8 +1025,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
dash_manifest_url = re.sub(r'/s/([a-fA-F0-9\.]+)', decrypt_sig, dash_manifest_url)
dash_doc = self._download_xml(
dash_manifest_url, video_id,
note='Downloading DASH manifest',
errnote='Could not download DASH manifest',
note=g('Downloading DASH manifest'),
errnote=g('Could not download DASH manifest'),
fatal=fatal)
if dash_doc is False:

View File

@ -22,6 +22,7 @@ from ..utils import (
subtitles_filename,
dfxp2srt,
ISO639Utils,
g,
)
@ -403,7 +404,7 @@ class FFmpegMergerPP(FFmpegPostProcessor):
filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp')
args = ['-c', 'copy', '-map', '0:v:0', '-map', '1:a:0']
self._downloader.to_screen('[ffmpeg] Merging formats into "%s"' % filename)
self._downloader.to_screen(g('[ffmpeg] Merging formats into "%s"') % filename)
self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
return info['__files_to_merge'], info