Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a couple strings that were not properly internationalized. #1173

Merged
merged 6 commits into from
Jun 7, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions SIL.Windows.Forms/ImageToolbox/AcquireImageControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public AcquireImageControl()

void _galleryControl_ImageChanged(object sender, EventArgs e)
{
//propogate that event to the outer toolbox
// Propagate that event to the outer toolbox
if (ImageChanged != null)
ImageChanged(sender, e);
}
Expand All @@ -50,9 +50,9 @@ private void OnGetFromFileSystemClick(object sender, EventArgs e)
if (_actModal)
return; // The GTK file chooser on Linux isn't acting modal, so we simulate it.
_actModal = true;
// Something in the Mono runtime state machine keeps the GTK filechooser from getting the
// Something in the Mono runtime state machine keeps the GTK file chooser from getting the
// focus immediately when we invoke OpenFileDialogWithViews.ShowDialog() directly at this
// point. Waiting for the next idle gets it into a state where the filechooser does receive
// point. Waiting for the next idle gets it into a state where the file chooser does receive
// the focus as desired. See https://silbloom.myjetbrains.com/youtrack/issue/BL-5809.
if (Platform.IsMono)
Application.Idle += DelayGetImageFileFromSystem;
Expand All @@ -74,7 +74,7 @@ private void DelayGetImageFileFromSystem(object sender, EventArgs e)
// load, but it's the default exception if anything is wrong with a file loaded by
// Image.FromFile(), so it could happen with a largish image that's corrupted;
// TagLib.CorruptFileException (most cases where file is not valid image data, though
// its main meaning is that specfically the metadata can't be read).
// its main meaning is that specifically the metadata can't be read).
public Action<string, Exception, string> ImageLoadingExceptionReporter { get; set; }

private void GetImageFileFromSystem()
Expand All @@ -97,7 +97,7 @@ private void GetImageFileFromSystem()

dlg.Title = "Choose Picture File".Localize("ImageToolbox.FileChooserTitle", "Title shown for a file chooser dialog brought up by the ImageToolbox");

//NB: dissallowed gif because of a .net crash: http://jira.palaso.org/issues/browse/BL-85
//NB: disallowed gif because of a .net crash: http://jira.palaso.org/issues/browse/BL-85
dlg.Filter = "picture files".Localize("ImageToolbox.PictureFiles", "Shown in the file-picking dialog to describe what kind of files the dialog is filtering for") + "(*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp)|*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.bmp;";

if (DialogResult.OK == dlg.ShowDialog(this.ParentForm))
Expand Down Expand Up @@ -166,7 +166,7 @@ private void OnDragDrop(object sender, DragEventArgs e)

BeginInvoke(new Action<string>(OpenFileFromDrag), s);

ParentForm.Activate(); // in the case Explorer overlaps this form
ParentForm?.Activate(); // in the case Explorer overlaps this form
}
}
catch (Exception)
Expand All @@ -183,14 +183,7 @@ public void SetImage(PalasoImage image)
_scannerButton.Checked = _cameraButton.Checked = false;
_currentImage = image;
SetMode(Modes.SingleImage);
if (image == null)
{
_pictureBox.Image = null;
}
else
{
_pictureBox.Image = image.Image;
}
_pictureBox.Image = image?.Image;
}

public PalasoImage GetImage()
Expand Down Expand Up @@ -264,17 +257,20 @@ private void GetFromDevice(ImageAcquisitionService.DeviceKind deviceKind)
// Interop.WIA by reflection, so any strings contained in methods that depend on WIA
// calls are omitted.
private string TwainDriverNotSupportedMessage =>
"Note: this program works with devices that have a 'WIA' driver, not the old-style " +
"'TWAIN' driver".Localize("ImageToolbox.TwainDriverNotSupported");
LocalizationManager.GetString("ImageToolbox.TwainDriverNotSupported",
"Note: this program works with devices that have a \"WIA\" driver, not the " +
"old-style \"TWAIN\" driver");

// This is a separate property because L10nSharp's extraction code cannot properly load
// Interop.WIA by reflection, so any strings contained in methods that depend on WIA
// calls are omitted.
private string WIAVersion2MissingMessage =>
string.Format(
LocalizationManager.GetString("ImageToolbox.WindowsXpMissingWiaV2Dll",
"Windows XP does not come with a crucial DLL that lets you use a WIA scanner with " +
"this program. Get a technical person to download and follow the directions at " +
"http://vbnet.mvps.org/files/updates/wiaautsdk.zip".Localize(
"ImageToolbox.WindowsXpMissingWiaV2Dll");
"this program. Get a technical person to download and follow the directions at {0}",
"Param 0: URL to download a zip file"),
"http://vbnet.mvps.org/files/updates/wiaautsdk.zip");

// This is a separate property because L10nSharp's extraction code cannot properly load
// Interop.WIA by reflection, so any strings contained in methods that depend on WIA
Expand Down Expand Up @@ -302,7 +298,7 @@ public string SearchLanguage

/*
/// <summary>
/// Bitmaps --> PNG, JPEGs stay as jpegs.
/// Bitmaps --> PNG, JPEGs stay as JPEGs.
/// Will delete the incoming file if it needs to do a conversion.
/// </summary>
private string ConvertToPngOrJpegIfNotAlready(string incoming)
Expand Down Expand Up @@ -344,8 +340,6 @@ private string ConvertToPngOrJpegIfNotAlready(string incoming)

private string ConvertToPngOrJpegIfNotAlready(ImageFile wiaImageFile)
{
Image acquiredImage;//with my scanner, always a .bmp

var imageBytes = (byte[])wiaImageFile.FileData.get_BinaryData();
if (wiaImageFile.FileExtension == ".jpg" || wiaImageFile.FileExtension == ".png")
{
Expand All @@ -369,8 +363,8 @@ private string ConvertToPngOrJpegIfNotAlready(ImageFile wiaImageFile)
TempFile jpeg = TempFile.WithExtension(".jpg");
TempFile png = TempFile.WithExtension(".png");

//DOCS: "You must keep the stream open for the lifetime of the Image."(maybe just true for jpegs)
using (acquiredImage = Image.FromStream(stream))
//DOCS: "You must keep the stream open for the lifetime of the Image." (maybe just true for jpeg images)
using (var acquiredImage = Image.FromStream(stream))
{
acquiredImage.Save(jpeg.Path, ImageFormat.Jpeg);
acquiredImage.Save(png.Path, ImageFormat.Png);
Expand Down Expand Up @@ -410,7 +404,7 @@ private void SetMode(Modes mode)
_galleryControl.Visible = false;
break;
default:
throw new ArgumentOutOfRangeException("mode");
throw new ArgumentOutOfRangeException(nameof(mode));
}
}

Expand All @@ -434,7 +428,7 @@ private void AcquireImageControl_Load(object sender, EventArgs e)
}
// This control can get loaded when the overall dialog is being disposed.
// See https://issues.bloomlibrary.org/youtrack/issue/BL-10314 if you don't believe me.
Load -= new EventHandler(AcquireImageControl_Load);
Load -= AcquireImageControl_Load;
}

/// <summary>
Expand Down