[i18n] Use tr() instead of g()

This commit is contained in:
Yen Chi Hsuan 2015-12-13 03:33:40 +08:00
parent 4fe08dc18d
commit d8257c57d8
9 changed files with 22 additions and 22 deletions

View File

@ -74,7 +74,7 @@ class I18N_Utils(object):
old_pot_file = self.get_pot_filename() + '.old'
shutil.copy2(pot_file, old_pot_file)
cmds = [
'xgettext', '-d', self.GETTEXT_DOMAIN, '-j', '-k', '-kg', '--from-code=utf-8', '-F', '-o',
'xgettext', '-d', self.GETTEXT_DOMAIN, '-j', '-k', '-ktr', '--from-code=utf-8', '-F', '-o',
pot_file]
cmds.extend(glob.glob('youtube_dl/*.py') + glob.glob('youtube_dl/*/*.py'))
self._run_subprocess(cmds)

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-13 00:33+0800\n"
"POT-Creation-Date: 2015-12-13 03:32+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -51,7 +51,6 @@ from .utils import (
ExtractorError,
format_bytes,
formatSeconds,
g,
locked_file,
make_HTTPS_handler,
MaxDownloadsReached,
@ -68,6 +67,7 @@ from .utils import (
sanitized_Request,
std_headers,
subtitles_filename,
tr,
UnavailableVideoError,
url_basename,
version_tuple,
@ -1546,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(g('[debug] Invoking downloader on %r') % info.get('url'))
self.to_stdout(tr('[debug] Invoking downloader on %r') % info.get('url'))
return fd.download(name, info)
if info_dict.get('requested_formats') is not None:
@ -1590,7 +1590,7 @@ class YoutubeDL(object):
filename = '%s.%s' % (filename_wo_ext, info_dict['ext'])
if os.path.exists(encodeFilename(filename)):
self.to_screen(
g('[download] %s has already been downloaded and '
tr('[download] %s has already been downloaded and '
'merged') % filename)
else:
for f in requested_formats:
@ -1724,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(g('Deleting original file %s (pass -k to keep)') % old_filename)
self.to_screen(tr('Deleting original file %s (pass -k to keep)') % old_filename)
try:
os.remove(encodeFilename(old_filename))
except (IOError, OSError):

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@ from ..utils import (
unsmuggle_url,
uppercase_escape,
ISO3166Utils,
g,
tr,
)
@ -744,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(g('%s: Downloading video info webpage') % video_id)
self.to_screen(tr('%s: Downloading video info webpage') % video_id)
def report_information_extraction(self, video_id):
"""Report attempt to extract video information."""
self.to_screen(g('%s: Extracting video information') % video_id)
self.to_screen(tr('%s: Extracting video information') % video_id)
def report_unavailable_format(self, video_id, format):
"""Report extracted video URL."""
@ -1025,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=g('Downloading DASH manifest'),
errnote=g('Could not download DASH manifest'),
note=tr('Downloading DASH manifest'),
errnote=tr('Could not download DASH manifest'),
fatal=fatal)
if dash_doc is False:

View File

@ -22,7 +22,7 @@ from ..utils import (
subtitles_filename,
dfxp2srt,
ISO639Utils,
g,
tr,
)
@ -404,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(g('[ffmpeg] Merging formats into "%s"') % filename)
self._downloader.to_screen(tr('[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

View File

@ -2513,7 +2513,7 @@ class ISO3166Utils(object):
return cls._country_map.get(code.upper())
def g(s):
def tr(s):
DOMAIN = 'youtube_dl'
lang, _ = locale.getdefaultlocale()
try: