Yet anothert localization patch from Jorma Karvonen. This one fixes #7116.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40512 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Siarzhuk Zharski 2011-02-15 17:03:01 +00:00
parent 8332dfe78c
commit 007d8a0cea
4 changed files with 86 additions and 54 deletions

View File

@ -13,3 +13,13 @@ Application MediaConverter :
: be media tracker $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSTDC++) : be media tracker $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSTDC++)
: MediaConverter.rdef : MediaConverter.rdef
; ;
DoCatalogs MediaConverter :
x-vnd.Haiku-MediaConverter
:
MediaFileInfoView.cpp
MediaFileInfo.cpp
MediaEncoderWindow.cpp
MediaConverterWindow.cpp
MediaConverterApp.cpp
;

View File

@ -137,16 +137,15 @@ MediaConverterApp::RefsReceived(BMessage* msg)
BString amount; BString amount;
amount << errors; amount << errors;
alertText.ReplaceAll("%amountOfFiles", amount); alertText.ReplaceAll("%amountOfFiles", amount);
} } else {
else
{
alertText = B_TRANSLATE( alertText = B_TRANSLATE(
"1 file were not recognized as supported media file:"); "The file was not recognized as a supported media file:");
} }
alertText << "\n" << errorFiles; alertText << "\n" << errorFiles;
BAlert* alert = new BAlert((errors > 1) ? BAlert* alert = new BAlert((errors > 1) ?
B_TRANSLATE("Error loading files") : B_TRANSLATE("Error loading files") :
B_TRANSLATE("Error loading file"), B_TRANSLATE("Error loading a file"),
alertText.String(), B_TRANSLATE("Continue") , NULL, NULL, alertText.String(), B_TRANSLATE("Continue") , NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT); B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go(); alert->Go();
@ -481,7 +480,8 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
if (fCancel) { if (fCancel) {
// don't have any video or audio tracks here, or cancelled // don't have any video or audio tracks here, or cancelled
printf("MediaConverterApp::_ConvertFile() - user canceld before transcoding\n"); printf("MediaConverterApp::_ConvertFile()"
" - user canceled before transcoding\n");
ret = B_CANCELED; ret = B_CANCELED;
} }
@ -529,31 +529,33 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
&mh)) != B_OK) { &mh)) != B_OK) {
fprintf(stderr, "Error reading video frame %Ld: %s\n", i, fprintf(stderr, "Error reading video frame %Ld: %s\n", i,
strerror(ret)); strerror(ret));
status.SetTo(B_TRANSLATE("Error read video frame ")); snprintf(status.LockBuffer(128), 128,
status << i; B_TRANSLATE("Error read video frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String()); SetStatusMessage(status.String());
break; break;
} }
//printf("writing frame %lld\n", i);
if ((ret = outVidTrack->WriteFrames(videoBuffer, framesRead, if ((ret = outVidTrack->WriteFrames(videoBuffer, framesRead,
mh.u.encoded_video.field_flags)) != B_OK) { mh.u.encoded_video.field_flags)) != B_OK) {
fprintf(stderr, "Error writing video frame %Ld: %s\n", i, fprintf(stderr, "Error writing video frame %Ld: %s\n", i,
strerror(ret)); strerror(ret));
status.SetTo(B_TRANSLATE("Error writing video frame ")); snprintf(status.LockBuffer(128), 128,
status << i; B_TRANSLATE("Error writing video frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String()); SetStatusMessage(status.String());
break; break;
} }
completePercent = (float)(i - start) / (float)(end - start) * 100; completePercent = (float)(i - start) / (float)(end - start) * 100;
currPercent = (int16)floor(completePercent); currPercent = (int16)floor(completePercent);
if (currPercent > lastPercent) { if (currPercent > lastPercent) {
lastPercent = currPercent; lastPercent = currPercent;
status.SetTo( snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Writing video track: %percent complete")); B_TRANSLATE("Writing video track: %Ld %% complete"),
BString percent; currPercent);
percent << currPercent << "%"; status.UnlockBuffer();
status.ReplaceAll("%percent", percent);
SetStatusMessage(status.String()); SetStatusMessage(status.String());
} }
@ -586,30 +588,32 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
if ((ret = inAudTrack->ReadFrames(audioBuffer, &framesRead, if ((ret = inAudTrack->ReadFrames(audioBuffer, &framesRead,
&mh)) != B_OK) { &mh)) != B_OK) {
fprintf(stderr, "Error reading audio frames: %s\n", strerror(ret)); fprintf(stderr, "Error reading audio frames: %s\n", strerror(ret));
status.SetTo(B_TRANSLATE("Error read audio frame ")); snprintf(status.LockBuffer(128), 128,
status << i; B_TRANSLATE("Error read audio frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String()); SetStatusMessage(status.String());
break; break;
} }
//printf("writing audio frames %lld\n", i);
if ((ret = outAudTrack->WriteFrames(audioBuffer, if ((ret = outAudTrack->WriteFrames(audioBuffer,
framesRead)) != B_OK) { framesRead)) != B_OK) {
fprintf(stderr, "Error writing audio frames: %s\n", fprintf(stderr, "Error writing audio frames: %s\n", strerror(ret));
strerror(ret)); snprintf(status.LockBuffer(128), 128,
status.SetTo(B_TRANSLATE("Error writing audio frame ")); B_TRANSLATE("Error writing audio frame %Ld"), i);
status << i; status.UnlockBuffer();
SetStatusMessage(status.String()); SetStatusMessage(status.String());
break; break;
} }
completePercent = (float)(i - start) / (float)(end - start) * 100; completePercent = (float)(i - start) / (float)(end - start) * 100;
currPercent = (int16)floor(completePercent); currPercent = (int16)floor(completePercent);
if (currPercent > lastPercent) { if (currPercent > lastPercent) {
lastPercent = currPercent; lastPercent = currPercent;
status.SetTo( snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Writing audio track: %percent complete")); B_TRANSLATE("Writing audio track: %Ld %% complete"),
BString percent; currPercent);
percent << currPercent << "%"; status.UnlockBuffer();
status.ReplaceAll("%percent", percent);
SetStatusMessage(status.String()); SetStatusMessage(status.String());
} }
} }

View File

@ -110,8 +110,9 @@ CodecMenuItem::~CodecMenuItem()
MediaConverterWindow::MediaConverterWindow(BRect frame) MediaConverterWindow::MediaConverterWindow(BRect frame)
: :
BWindow(frame, "MediaConverter", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, BWindow(frame, B_TRANSLATE("MediaConverter"), B_TITLED_WINDOW_LOOK,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
B_AUTO_UPDATE_SIZE_LIMITS),
fVideoQuality(75), fVideoQuality(75),
fAudioQuality(75), fAudioQuality(75),
fSaveFilePanel(NULL), fSaveFilePanel(NULL),
@ -386,13 +387,13 @@ MediaConverterWindow::MessageReceived(BMessage* msg)
{ {
BString title(B_TRANSLATE("About" B_UTF8_ELLIPSIS)); BString title(B_TRANSLATE("About" B_UTF8_ELLIPSIS));
(new BAlert(title, (new BAlert(title,
"MediaConverter\n" B_TRANSLATE("MediaConverter\n"
VERSION"\n" VERSION"\n"
B_UTF8_COPYRIGHT" 1999, Be Incorporated.\n" B_UTF8_COPYRIGHT" 1999, Be Incorporated.\n"
B_UTF8_COPYRIGHT" 2000-2004 Jun Suzuki\n" B_UTF8_COPYRIGHT" 2000-2004 Jun Suzuki\n"
B_UTF8_COPYRIGHT" 2007 Stephan Aßmus\n" B_UTF8_COPYRIGHT" 2007 Stephan Aßmus\n"
B_UTF8_COPYRIGHT" 2010 Haiku, Inc.", B_UTF8_COPYRIGHT" 2010 Haiku, Inc."),
B_TRANSLATE("OK")))->Go(); B_TRANSLATE("OK")))->Go();
break; break;
} }
@ -436,10 +437,9 @@ MediaConverterWindow::MessageReceived(BMessage* msg)
} }
if (status != B_OK && status != B_ALREADY_RUNNING) { if (status != B_OK && status != B_ALREADY_RUNNING) {
BString errorString; BString errorString(B_TRANSLATE("Error launching: %strError%"));
errorString << B_TRANSLATE("Error launching: ") << errorString.ReplaceFirst("%strError%", strerror(status));
strerror(status); (new BAlert(B_TRANSLATE("Error"), errorString.String(),
(new BAlert("", errorString.String(),
B_TRANSLATE("OK")))->Go(); B_TRANSLATE("OK")))->Go();
} }
break; break;

View File

@ -7,8 +7,12 @@
#include "MediaFileInfo.h" #include "MediaFileInfo.h"
#include <Catalog.h>
#include <MediaTrack.h> #include <MediaTrack.h>
#include <stdio.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "MediaFileInfo"
MediaFileInfo::MediaFileInfo(BMediaFile* file) MediaFileInfo::MediaFileInfo(BMediaFile* file)
{ {
@ -64,11 +68,14 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
videoDuration = track->Duration(); videoDuration = track->Duration();
videoFrames = track->CountFrames(); videoFrames = track->CountFrames();
video.details << (int32)format.Width() << "x" BString details;
<< (int32)format.Height() << " " snprintf(details.LockBuffer(256), 256,
<< (int32)(rvf->field_rate / rvf->interlace) B_TRANSLATE_COMMENT("%Ld x %Ld, %Ld fps / %Ld frames",
<< " fps / " << videoFrames << " frames"; "Width x Height, fps / frames"),
format.Width(), format.Height(),
rvf->field_rate / rvf->interlace, videoFrames);
details.UnlockBuffer();
video.details << details;
videoDone = true; videoDone = true;
} else if (format.IsAudio()) { } else if (format.IsAudio()) {
@ -80,13 +87,17 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
media_raw_audio_format *raf = &(format.u.raw_audio); media_raw_audio_format *raf = &(format.u.raw_audio);
char bytesPerSample = (char)(raf->format & 0xf); char bytesPerSample = (char)(raf->format & 0xf);
if (bytesPerSample == 1) {
audio.details << "8 bit "; BString details;
} else if (bytesPerSample == 2) { if (bytesPerSample == 1 || bytesPerSample == 2) {
audio.details << "16 bit "; snprintf(details.LockBuffer(16), 16,
B_TRANSLATE("%d bit "), bytesPerSample * 8);
} else { } else {
audio.details << bytesPerSample << "byte "; snprintf(details.LockBuffer(16), 16,
B_TRANSLATE("%d byte "), bytesPerSample);
} }
details.UnlockBuffer();
audio.details << details;
ret = track->GetCodecInfo(&codecInfo); ret = track->GetCodecInfo(&codecInfo);
if (ret != B_OK) if (ret != B_OK)
@ -96,16 +107,23 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
audioDuration = track->Duration(); audioDuration = track->Duration();
audioFrames = track->CountFrames(); audioFrames = track->CountFrames();
audio.details << (float)(raf->frame_rate / 1000.0f) << " kHz"; BString channels;
if (raf->channel_count == 1) { if (raf->channel_count == 1) {
audio.details << " mono / "; snprintf(channels.LockBuffer(64), 64,
B_TRANSLATE("%.1f kHz mono / %lld frames"),
raf->frame_rate / 1000.f, audioFrames);
} else if (raf->channel_count == 2) { } else if (raf->channel_count == 2) {
audio.details << " stereo / "; snprintf(channels.LockBuffer(64), 64,
B_TRANSLATE("%.1f kHz stereo / %lld frames"),
raf->frame_rate / 1000.f, audioFrames);
} else { } else {
audio.details << (int32)raf->channel_count snprintf(channels.LockBuffer(64), 64,
<< " channel / " ; B_TRANSLATE("%.1f kHz %ld channel / %lld frames"),
raf->frame_rate / 1000.f, raf->channel_count, audioFrames);
} }
audio.details << audioFrames << " frames"; channels.UnlockBuffer();
audio.details << channels;
audioDone = true; audioDone = true;
} }
ret = file->ReleaseTrack(track); ret = file->ReleaseTrack(track);
@ -116,7 +134,7 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
useconds = MAX(audioDuration, videoDuration); useconds = MAX(audioDuration, videoDuration);
duration << (int32)(useconds / 1000000) duration << (int32)(useconds / 1000000)
<< " seconds"; << B_TRANSLATE(" seconds");
return B_OK; return B_OK;
} }