Skip to content

Commit

Permalink
localize
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Aug 16, 2023
1 parent d46c00a commit 037413e
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/Beutl.Engine/Graphics/FilterEffects/Brightness.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class Brightness : FilterEffect
Expand All @@ -17,6 +19,7 @@ static Brightness()
AffectsRender<Brightness>(AmountProperty);
}

[Display(Name = nameof(Strings.Amount), ResourceType = typeof(Strings))]
[Range(0, float.MaxValue)]
public float Amount
{
Expand Down
7 changes: 6 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/Clipping.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using SkiaSharp;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

using SkiaSharp;

namespace Beutl.Graphics.Effects;

Expand All @@ -16,6 +20,7 @@ static Clipping()
AffectsRender<Clipping>(ThicknessProperty);
}

[Display(Name = nameof(Strings.Thickness), ResourceType = typeof(Strings))]
public Thickness Thickness
{
get => _thickness;
Expand Down
8 changes: 7 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/Dilate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Beutl.Graphics.Effects;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class Dilate : FilterEffect
{
Expand All @@ -20,12 +24,14 @@ static Dilate()
AffectsRender<Dilate>(RadiusXProperty, RadiusYProperty);
}

[Display(Name = nameof(Strings.RadiusX), ResourceType = typeof(Strings))]
public float RadiusX
{
get => _radiusX;
set => SetAndRaise(RadiusXProperty, ref _radiusX, value);
}

[Display(Name = nameof(Strings.RadiusY), ResourceType = typeof(Strings))]
public float RadiusY
{
get => _radiusY;
Expand Down
8 changes: 7 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/Erode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Beutl.Graphics.Effects;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class Erode : FilterEffect
{
Expand All @@ -20,12 +24,14 @@ static Erode()
AffectsRender<Erode>(RadiusXProperty, RadiusYProperty);
}

[Display(Name = nameof(Strings.RadiusX), ResourceType = typeof(Strings))]
public float RadiusX
{
get => _radiusX;
set => SetAndRaise(RadiusXProperty, ref _radiusX, value);
}

[Display(Name = nameof(Strings.RadiusY), ResourceType = typeof(Strings))]
public float RadiusY
{
get => _radiusY;
Expand Down
4 changes: 4 additions & 0 deletions src/Beutl.Engine/Graphics/FilterEffects/Gamma.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class Gamma : FilterEffect
Expand All @@ -24,13 +26,15 @@ static Gamma()
AffectsRender<Gamma>(AmountProperty, StrengthProperty);
}

[Display(Name = nameof(Strings.Amount), ResourceType = typeof(Strings))]
[Range(1, 300)]
public float Amount
{
get => _amount;
set => SetAndRaise(AmountProperty, ref _amount, value);
}

[Display(Name = nameof(Strings.Strength), ResourceType = typeof(Strings))]
[Range(0, 100)]
public float Strength
{
Expand Down
9 changes: 8 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/HighContrast.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Beutl.Graphics.Effects;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class HighContrast : FilterEffect
{
Expand Down Expand Up @@ -26,18 +30,21 @@ static HighContrast()
AffectsRender<HighContrast>(GrayscaleProperty, InvertStyleProperty, ContrastProperty);
}

[Display(Name = nameof(Strings.Grayscale), ResourceType = typeof(Strings))]
public bool Grayscale
{
get => _grayscale;
set => SetAndRaise(GrayscaleProperty, ref _grayscale, value);
}

[Display(Name = nameof(Strings.InvertStyle), ResourceType = typeof(Strings))]
public HighContrastInvertStyle InvertStyle
{
get => _invertStyle;
set => SetAndRaise(InvertStyleProperty, ref _invertStyle, value);
}

[Display(Name = nameof(Strings.Contrast), ResourceType = typeof(Strings))]
public float Contrast
{
get => _contrast;
Expand Down
7 changes: 6 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/HueRotate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Beutl.Graphics.Effects;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class HueRotate : FilterEffect
{
Expand All @@ -14,6 +18,7 @@ static HueRotate()
AffectsRender<HueRotate>(AngleProperty);
}

[Display(Name = nameof(Strings.Angle), ResourceType = typeof(Strings))]
public float Angle
{
get => _angle;
Expand Down
3 changes: 3 additions & 0 deletions src/Beutl.Engine/Graphics/FilterEffects/Invert.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System.Reactive;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class Invert : FilterEffect
Expand All @@ -19,6 +21,7 @@ static Invert()
}

[Range(0, 100)]
[Display(Name = nameof(Strings.Amount), ResourceType = typeof(Strings))]
public float Amount
{
get => _amount;
Expand Down
7 changes: 6 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/Lighting.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Beutl.Media;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;
using Beutl.Media;

namespace Beutl.Graphics.Effects;

Expand All @@ -23,12 +26,14 @@ static Lighting()
AffectsRender<Lighting>(MultiplyProperty, AddProperty);
}

[Display(Name = nameof(Strings.Multiplication), ResourceType = typeof(Strings))]
public Color Multiply
{
get => _multiply;
set => SetAndRaise(MultiplyProperty, ref _multiply, value);
}

[Display(Name = nameof(Strings.Addition), ResourceType = typeof(Strings))]
public Color Add
{
get => _add;
Expand Down
2 changes: 2 additions & 0 deletions src/Beutl.Engine/Graphics/FilterEffects/LutEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

using Beutl.Language;
using Beutl.Media;
using Beutl.Rendering;

Expand Down Expand Up @@ -69,6 +70,7 @@ private void OnSourceChanged(FileInfo? value)
}
}

[Display(Name = nameof(Strings.Strength), ResourceType = typeof(Strings))]
[Range(0, 100)]
public float Strength
{
Expand Down
7 changes: 6 additions & 1 deletion src/Beutl.Engine/Graphics/FilterEffects/Saturate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Beutl.Graphics.Effects;
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

namespace Beutl.Graphics.Effects;

public sealed class Saturate : FilterEffect
{
Expand All @@ -15,6 +19,7 @@ static Saturate()
AffectsRender<Saturate>(AmountProperty);
}

[Display(Name = nameof(Strings.Amount), ResourceType = typeof(Strings))]
public float Amount
{
get => _amount;
Expand Down
4 changes: 4 additions & 0 deletions src/Beutl.Engine/Graphics/FilterEffects/Threshold.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.ComponentModel.DataAnnotations;

using Beutl.Language;

using SkiaSharp;

namespace Beutl.Graphics.Effects;
Expand All @@ -26,13 +28,15 @@ static Threshold()
AffectsRender<Threshold>(ValueProperty, StrengthProperty);
}

[Display(Name = nameof(Strings.Amount), ResourceType = typeof(Strings))]
[Range(0, 100)]
public float Value
{
get => _value;
set => SetAndRaise(ValueProperty, ref _value, value);
}

[Display(Name = nameof(Strings.Strength), ResourceType = typeof(Strings))]
[Range(0, 100)]
public float Strength
{
Expand Down
9 changes: 7 additions & 2 deletions src/Beutl.Engine/Graphics/FilterEffects/TransformEffect.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Beutl.Animation;
using System.ComponentModel.DataAnnotations;

using Beutl.Animation;
using Beutl.Graphics.Transformation;
using Beutl.Language;
using Beutl.Media;

namespace Beutl.Graphics.Effects;
Expand All @@ -20,18 +23,20 @@ static TransformEffect()

BitmapInterpolationModeProperty = ConfigureProperty<BitmapInterpolationMode, TransformEffect>(nameof(BitmapInterpolationMode))
.Accessor(o => o.BitmapInterpolationMode, (o, v) => o.BitmapInterpolationMode = v)
.DefaultValue(Media.BitmapInterpolationMode.Default)
.DefaultValue(BitmapInterpolationMode.Default)
.Register();

AffectsRender<TransformEffect>(TransformProperty, BitmapInterpolationModeProperty);
}

[Display(Name = nameof(Strings.Transform), ResourceType = typeof(Strings))]
public ITransform? Transform
{
get => _transform;
set => SetAndRaise(TransformProperty, ref _transform, value);
}

[Display(Name = nameof(Strings.BitmapInterpolationMode), ResourceType = typeof(Strings))]
public BitmapInterpolationMode BitmapInterpolationMode
{
get => _interpolationMode;
Expand Down
8 changes: 1 addition & 7 deletions src/Beutl.Language/LocalizeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ public bool IsSupportedCulture(CultureInfo ci)
return _supported.Contains(ci.Name);
}

public Uri GetUri(CultureInfo ci)
{
if (!IsSupportedCulture(ci)) throw new InvalidOperationException();
return new Uri($"avares://Beutl.Language/{ci.Name}/CommonResources.axaml");
}

public IEnumerable<CultureInfo> SupportedCultures()
{
return _supported.Select(n => CultureInfo.GetCultureInfo(n));
return _supported.Select(CultureInfo.GetCultureInfo);
}
}
Loading

0 comments on commit 037413e

Please sign in to comment.