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++)
: 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;
amount << errors;
alertText.ReplaceAll("%amountOfFiles", amount);
}
else
{
} else {
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;
BAlert* alert = new BAlert((errors > 1) ?
B_TRANSLATE("Error loading files") :
B_TRANSLATE("Error loading file"),
B_TRANSLATE("Error loading a file"),
alertText.String(), B_TRANSLATE("Continue") , NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
@ -481,7 +480,8 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
if (fCancel) {
// 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;
}
@ -529,31 +529,33 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
&mh)) != B_OK) {
fprintf(stderr, "Error reading video frame %Ld: %s\n", i,
strerror(ret));
status.SetTo(B_TRANSLATE("Error read video frame "));
status << i;
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Error read video frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String());
break;
}
//printf("writing frame %lld\n", i);
if ((ret = outVidTrack->WriteFrames(videoBuffer, framesRead,
mh.u.encoded_video.field_flags)) != B_OK) {
fprintf(stderr, "Error writing video frame %Ld: %s\n", i,
strerror(ret));
status.SetTo(B_TRANSLATE("Error writing video frame "));
status << i;
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Error writing video frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String());
break;
}
completePercent = (float)(i - start) / (float)(end - start) * 100;
currPercent = (int16)floor(completePercent);
if (currPercent > lastPercent) {
lastPercent = currPercent;
status.SetTo(
B_TRANSLATE("Writing video track: %percent complete"));
BString percent;
percent << currPercent << "%";
status.ReplaceAll("%percent", percent);
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Writing video track: %Ld %% complete"),
currPercent);
status.UnlockBuffer();
SetStatusMessage(status.String());
}
@ -586,30 +588,32 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
if ((ret = inAudTrack->ReadFrames(audioBuffer, &framesRead,
&mh)) != B_OK) {
fprintf(stderr, "Error reading audio frames: %s\n", strerror(ret));
status.SetTo(B_TRANSLATE("Error read audio frame "));
status << i;
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Error read audio frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String());
break;
}
//printf("writing audio frames %lld\n", i);
if ((ret = outAudTrack->WriteFrames(audioBuffer,
framesRead)) != B_OK) {
fprintf(stderr, "Error writing audio frames: %s\n",
strerror(ret));
status.SetTo(B_TRANSLATE("Error writing audio frame "));
status << i;
fprintf(stderr, "Error writing audio frames: %s\n", strerror(ret));
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Error writing audio frame %Ld"), i);
status.UnlockBuffer();
SetStatusMessage(status.String());
break;
}
completePercent = (float)(i - start) / (float)(end - start) * 100;
currPercent = (int16)floor(completePercent);
if (currPercent > lastPercent) {
lastPercent = currPercent;
status.SetTo(
B_TRANSLATE("Writing audio track: %percent complete"));
BString percent;
percent << currPercent << "%";
status.ReplaceAll("%percent", percent);
snprintf(status.LockBuffer(128), 128,
B_TRANSLATE("Writing audio track: %Ld %% complete"),
currPercent);
status.UnlockBuffer();
SetStatusMessage(status.String());
}
}

View File

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

View File

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