Skip to content

Commit

Permalink
Add lang query to URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
clown committed Aug 6, 2021
1 parent 66d68e4 commit 5d2ea43
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
18 changes: 16 additions & 2 deletions Applications/Converter/Main/Sources/Models/ViewResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
/* ------------------------------------------------------------------------- */
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using Cube.FileSystem;
using Cube.Mixin.Uri;
using Cube.Pdf.Ghostscript;

namespace Cube.Pdf.Converter
Expand All @@ -46,7 +48,7 @@ public static class ViewResource
/// </summary>
///
/* ----------------------------------------------------------------- */
public static Uri ProductUri { get; } = new Uri("https://www.cube-soft.jp/cubepdf/");
public static Uri ProductUri => GetUri("https://www.cube-soft.jp/cubepdf/");

/* ----------------------------------------------------------------- */
///
Expand All @@ -57,7 +59,7 @@ public static class ViewResource
/// </summary>
///
/* ----------------------------------------------------------------- */
public static Uri DocumentUri { get; } = new Uri("https://docs.cube-soft.jp/entry/cubepdf");
public static Uri DocumentUri => GetUri("https://docs.cube-soft.jp/entry/cubepdf");

/* ----------------------------------------------------------------- */
///
Expand Down Expand Up @@ -289,6 +291,18 @@ public static string WordWrap(this string src, int n) =>
/* ----------------------------------------------------------------- */
private static KeyValuePair<K, V> Make<K, V>(K key, V value) => new(key, value);

/* ----------------------------------------------------------------- */
///
/// GetUri
///
/// <summary>
/// Gets the Uri object from the specified URL string.
/// </summary>
///
/* ----------------------------------------------------------------- */
private static Uri GetUri(string url) =>
new Uri(url).With("lang", CultureInfo.CurrentCulture.Name.ToLowerInvariant());

#endregion

#region Fields
Expand Down
18 changes: 16 additions & 2 deletions Applications/Editor/Main/Sources/Models/SettingFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using Cube.FileSystem;
using Cube.FileSystem.DataContract;
using Cube.Mixin.Assembly;
using Cube.Mixin.Uri;

namespace Cube.Pdf.Editor
{
Expand Down Expand Up @@ -114,7 +116,7 @@ public SettingFolder(Assembly assembly, Format format, string location) :
/// </summary>
///
/* ----------------------------------------------------------------- */
public Uri ProductUri { get; } = new("https://www.cube-soft.jp/cubepdfutility/");
public Uri ProductUri => GetUri("https://www.cube-soft.jp/cubepdfutility/");

/* ----------------------------------------------------------------- */
///
Expand All @@ -125,7 +127,7 @@ public SettingFolder(Assembly assembly, Format format, string location) :
/// </summary>
///
/* ----------------------------------------------------------------- */
public Uri DocumentUri { get; } = new("https://docs.cube-soft.jp/entry/cubepdf-utility");
public Uri DocumentUri => GetUri("https://docs.cube-soft.jp/entry/cubepdf-utility");

#endregion

Expand Down Expand Up @@ -196,6 +198,18 @@ protected override void OnPropertyChanged(PropertyChangedEventArgs e)
finally { base.OnPropertyChanged(e); }
}

/* ----------------------------------------------------------------- */
///
/// GetUri
///
/// <summary>
/// Gets the Uri object from the specified URL string.
/// </summary>
///
/* ----------------------------------------------------------------- */
private Uri GetUri(string url) =>
new Uri(url).With("lang", CultureInfo.CurrentCulture.Name.ToLowerInvariant());

#endregion
}
}
2 changes: 1 addition & 1 deletion Tests/Converter/Sources/Presenters/OtherViewModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void MainViewModel() => Invoke(vm =>
Assert.That(vm.Title, Does.StartWith(nameof(MainViewModel)));
Assert.That(vm.Title, Does.Contain("CubePDF 1.5.1"));
Assert.That(vm.Version, Does.StartWith("1.5.1 (").And.EndsWith(")"));
Assert.That(vm.Uri, Is.EqualTo(new Uri("https://www.cube-soft.jp/cubepdf/")));
Assert.That(vm.Uri.ToString(), Does.StartWith("https://www.cube-soft.jp/cubepdf/?lang="));
});

/* ----------------------------------------------------------------- */
Expand Down
22 changes: 11 additions & 11 deletions Tests/Editor/Sources/Presenters/SettingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ public void Cancel() => Open("Sample.pdf", "", vm =>
var cts = new CancellationTokenSource();
_ = vm.Subscribe<SettingViewModel>(e =>
{
Assert.That(e.Title, Is.Not.Null.And.Not.Empty);
Assert.That(e.Version.Text, Is.Not.Null.And.Not.Empty);
Assert.That(e.Version.Value, Does.StartWith("Cube.Pdf.Editor.Tests 1.5.1 "));
Assert.That(e.Windows.Text, Does.StartWith("Microsoft Windows"));
Assert.That(e.Framework.Text, Does.StartWith("Microsoft .NET Framework"));
Assert.That(e.Link.Text, Is.EqualTo("Copyright © 2013 CubeSoft, Inc."));
Assert.That(e.Link.Value, Is.EqualTo(new Uri("https://www.cube-soft.jp/cubepdfutility/")));
Assert.That(e.Update.Text, Is.Not.Null.And.Not.Empty);
Assert.That(e.Language.Text, Is.Not.Null.And.Not.Empty);
Assert.That(e.Language.Value, Is.EqualTo(Language.Auto));
Assert.That(e.Languages.Count(), Is.EqualTo(3));
Assert.That(e.Title, Is.Not.Null.And.Not.Empty);
Assert.That(e.Version.Text, Is.Not.Null.And.Not.Empty);
Assert.That(e.Version.Value, Does.StartWith("Cube.Pdf.Editor.Tests 1.5.1 "));
Assert.That(e.Windows.Text, Does.StartWith("Microsoft Windows"));
Assert.That(e.Framework.Text, Does.StartWith("Microsoft .NET Framework"));
Assert.That(e.Link.Text, Is.EqualTo("Copyright © 2013 CubeSoft, Inc."));
Assert.That(e.Link.Value.ToString(), Does.StartWith("https://www.cube-soft.jp/cubepdfutility/?lang="));
Assert.That(e.Update.Text, Is.Not.Null.And.Not.Empty);
Assert.That(e.Language.Text, Is.Not.Null.And.Not.Empty);
Assert.That(e.Language.Value, Is.EqualTo(Language.Auto));
Assert.That(e.Languages.Count(), Is.EqualTo(3));

Assert.That(e.OK.Command.CanExecute(), Is.True);
Assert.That(e.Cancel.Command.CanExecute(), Is.True);
Expand Down

0 comments on commit 5d2ea43

Please sign in to comment.