Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add localization to SearchPanel

  • Loading branch information...
commit 6d219a7927076553f884d54dac0d8ce37429fe13 1 parent d33c478
@siegfriedpammer siegfriedpammer authored
View
1  src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
@@ -290,6 +290,7 @@
<Compile Include="Rendering\VisualYPosition.cs">
<DependentUpon>VisualLine.cs</DependentUpon>
</Compile>
+ <Compile Include="Search\Localization.cs" />
<Compile Include="Search\RegexSearchStrategy.cs" />
<Compile Include="Search\DropDownButton.cs" />
<Compile Include="Search\ISearchStrategy.cs" />
View
65 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/Localization.cs
@@ -0,0 +1,65 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.ComponentModel;
+
+namespace ICSharpCode.AvalonEdit
+{
+ /// <summary>
+ /// Holds default texts for buttons and labels in the SearchPanel. Override properties to add other languages.
+ /// </summary>
+ public class Localization
+ {
+ /// <summary>
+ /// Default: 'Match case'
+ /// </summary>
+ public virtual string MatchCaseText {
+ get { return "Match case"; }
+ }
+
+ /// <summary>
+ /// Default: 'Match whole words'
+ /// </summary>
+ public virtual string MatchWholeWordsText {
+ get { return "Match whole words"; }
+ }
+
+
+ /// <summary>
+ /// Default: 'Use regular expressions'
+ /// </summary>
+ public virtual string UseRegexText {
+ get { return "Use regular expressions"; }
+ }
+
+ /// <summary>
+ /// Default: 'Find next (F3)'
+ ///
+ /// </summary>
+ public virtual string FindNextText {
+ get { return "Find next (F3)"; }
+ }
+
+ /// <summary>
+ /// Default: 'Find previous (Shift+F3)'
+ /// </summary>
+ public virtual string FindPreviousText {
+ get { return "Find previous (Shift+F3)"; }
+ }
+
+ /// <summary>
+ /// Default: 'Error: '
+ /// </summary>
+ public virtual string ErrorText {
+ get { return "Error: "; }
+ }
+
+ /// <summary>
+ /// Default: 'No matches found!'
+ /// </summary>
+ public virtual string NoMatchesFoundText {
+ get { return "No matches found!"; }
+ }
+ }
+}
View
21 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs
@@ -33,6 +33,7 @@ public class SearchPanel : Control
TextBox searchTextBox;
SearchPanelAdorner adorner;
+ #region DependencyProperties
/// <summary>
/// Dependency property for <see cref="UseRegex"/>.
/// </summary>
@@ -108,6 +109,22 @@ public class SearchPanel : Control
set { SetValue(MarkerBrushProperty, value); }
}
+ /// <summary>
+ /// Dependency property for <see cref="Localization"/>.
+ /// </summary>
+ public static readonly DependencyProperty LocalizationProperty =
+ DependencyProperty.Register("Localization", typeof(Localization), typeof(SearchPanel),
+ new FrameworkPropertyMetadata(new Localization()));
+
+ /// <summary>
+ /// Gets/sets the localization for the SearchPanel.
+ /// </summary>
+ public Localization Localization {
+ get { return (Localization)GetValue(LocalizationProperty); }
+ set { SetValue(LocalizationProperty, value); }
+ }
+ #endregion
+
static void MarkerBrushChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
SearchPanel panel = d as SearchPanel;
@@ -275,7 +292,7 @@ void DoSearch(bool changeSelection)
}
if (!renderer.CurrentResults.Any()) {
messageView.IsOpen = true;
- messageView.Content = "No matches found!";
+ messageView.Content = Localization.NoMatchesFoundText;
messageView.PlacementTarget = searchTextBox;
} else
messageView.IsOpen = false;
@@ -310,7 +327,7 @@ void SearchLayerKeyDown(object sender, KeyEventArgs e)
if (searchTextBox != null) {
var error = Validation.GetErrors(searchTextBox).FirstOrDefault();
if (error != null) {
- messageView.Content = "Error: " + error.ErrorContent;
+ messageView.Content = Localization.ErrorText + error.ErrorContent;
messageView.PlacementTarget = searchTextBox;
messageView.IsOpen = true;
}
View
10 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.xaml
@@ -20,18 +20,18 @@
<Popup StaysOpen="False">
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" BorderThickness="1">
<StackPanel Orientation="Vertical">
- <CheckBox IsChecked="{Binding MatchCase, RelativeSource={RelativeSource TemplatedParent}}" Content="Match case" Margin="3" />
- <CheckBox IsChecked="{Binding WholeWords, RelativeSource={RelativeSource TemplatedParent}}" Content="Match whole words" Margin="3" />
- <CheckBox IsChecked="{Binding UseRegex, RelativeSource={RelativeSource TemplatedParent}}" Content="Use Regular Expressions" Margin="3" />
+ <CheckBox IsChecked="{Binding MatchCase, RelativeSource={RelativeSource TemplatedParent}}" Content="{Binding Localization.MatchCaseText, RelativeSource={RelativeSource TemplatedParent}}" Margin="3" />
+ <CheckBox IsChecked="{Binding WholeWords, RelativeSource={RelativeSource TemplatedParent}}" Content="{Binding Localization.MatchWholeWordsText, RelativeSource={RelativeSource TemplatedParent}}" Margin="3" />
+ <CheckBox IsChecked="{Binding UseRegex, RelativeSource={RelativeSource TemplatedParent}}" Content="{Binding Localization.UseRegexText, RelativeSource={RelativeSource TemplatedParent}}" Margin="3" />
</StackPanel>
</Border>
</Popup>
</search:DropDownButton.DropDownContent>
</search:DropDownButton>
- <Button Margin="3" Height="24" Width="24" Command="search:SearchCommands.FindPrevious" ToolTip="Find Next (Shift+F3)">
+ <Button Margin="3" Height="24" Width="24" Command="search:SearchCommands.FindPrevious" ToolTip="{Binding Localization.FindPreviousText, RelativeSource={RelativeSource TemplatedParent}}">
<Image Width="16" Height="16" Stretch="Fill" Source="prev.png" />
</Button>
- <Button Margin="3" Height="24" Width="24" Command="search:SearchCommands.FindNext" ToolTip="Find Next (F3)">
+ <Button Margin="3" Height="24" Width="24" Command="search:SearchCommands.FindNext" ToolTip="{Binding Localization.FindNextText, RelativeSource={RelativeSource TemplatedParent}}">
<Image Width="16" Height="16" Stretch="Fill" Source="next.png" />
</Button>
<Button Height="16" Width="16" HorizontalAlignment="Right" VerticalAlignment="Top" Command="search:SearchCommands.CloseSearchPanel"
Please sign in to comment.
Something went wrong with that request. Please try again.