-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect NeutralResourcesLanguageAttribute. Fix #19
- Loading branch information
1 parent
fee3de8
commit 6a0ebfa
Showing
24 changed files
with
785 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Gu.Wpf.Localization.UiTests/Gu.Wpf.Localization.UiTests.csproj.DotSettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helpers/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Gu.Wpf.Localization.UiTests | ||
{ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
public static class StartInfo | ||
{ | ||
public static ProcessStartInfo DemoProject { get; } = CreateStartUpInfo("Gu.Wpf.Localization.Demo", CultureInfo.GetCultureInfo("en")); | ||
|
||
public static ProcessStartInfo WithNeutralLanguageProject { get; } = CreateStartUpInfo("Gu.Wpf.Localization.WithNeutralLanguage", CultureInfo.GetCultureInfo("en")); | ||
|
||
private static ProcessStartInfo CreateStartUpInfo(string assemblyName, CultureInfo culture) | ||
{ | ||
var processStartInfo = new ProcessStartInfo | ||
{ | ||
Arguments = culture.Name, | ||
FileName = GetExeFileName(assemblyName), | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true | ||
}; | ||
return processStartInfo; | ||
} | ||
|
||
private static string GetExeFileName(string assemblyName) | ||
{ | ||
var testAssembnly = Assembly.GetExecutingAssembly(); | ||
var testDirestory = Path.GetDirectoryName(new Uri(testAssembnly.CodeBase).AbsolutePath); | ||
var exeDirectory = testDirestory.Replace(testAssembnly.GetName().Name, assemblyName); | ||
var fileName = Path.Combine(exeDirectory, $"{assemblyName}.exe"); | ||
return fileName; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Gu.Wpf.Localization.UiTests | ||
{ | ||
using TestStack.White.UIItems; | ||
using TestStack.White.UIItems.Finders; | ||
|
||
public static class UiItemExt | ||
{ | ||
public static string ItemStatus(this IUIItem item) | ||
{ | ||
return (string)item.AutomationElement.Current.ItemStatus; | ||
} | ||
|
||
public static T GetByText<T>(this UIItemContainer container, string text) | ||
where T : UIItem | ||
{ | ||
return container.Get<T>(SearchCriteria.ByText(text)); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Gu.Wpf.Localization.UiTests/TranslatesWithNeutralLanguage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace Gu.Wpf.Localization.UiTests | ||
{ | ||
using NUnit.Framework; | ||
using TestStack.White; | ||
using TestStack.White.UIItems; | ||
using TestStack.White.UIItems.WindowItems; | ||
|
||
public class TranslatesWithNeutralLanguage | ||
{ | ||
private Application application; | ||
private Window window; | ||
|
||
[OneTimeSetUp] | ||
public void OneTimeSetUp() | ||
{ | ||
this.application = Application.AttachOrLaunch(StartInfo.WithNeutralLanguageProject); | ||
this.window = this.application.GetWindow("MainWindow"); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void OneTimeTearDown() | ||
{ | ||
this.application?.Dispose(); | ||
} | ||
|
||
[Test] | ||
public void EffectiveCulture() | ||
{ | ||
Assert.AreEqual("en", this.window.Get<Label>("CurrentCultureTextBlock").Text); | ||
this.window.Get<RadioButton>("pt").Click(); | ||
Assert.AreEqual("pt", this.window.Get<Label>("CurrentCultureTextBlock").Text); | ||
} | ||
|
||
[Test] | ||
public void VanillaXaml() | ||
{ | ||
this.window.Get<RadioButton>("en").Click(); | ||
var groupBox = this.window.GetByText<GroupBox>("Vanilla xaml"); | ||
Assert.AreEqual("English", groupBox.Get<Label>("AllLanguagesTextBlock").Text); | ||
|
||
this.window.Get<RadioButton>("pt").Click(); | ||
Assert.AreEqual("Português", groupBox.Get<Label>("AllLanguagesTextBlock").Text); | ||
|
||
this.window.Get<RadioButton>("en").Click(); | ||
Assert.AreEqual("English", groupBox.Get<Label>("AllLanguagesTextBlock").Text); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="Gu.Wpf.Localization.WithNeutralLanguage.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Gu.Wpf.Localization.WithNeutralLanguage" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Gu.Wpf.Localization.WithNeutralLanguage | ||
{ | ||
using System.Globalization; | ||
using System.Threading; | ||
using System.Windows; | ||
|
||
public partial class App : Application | ||
{ | ||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
if (e.Args.Length == 1) | ||
{ | ||
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(e.Args[0]); | ||
} | ||
|
||
base.OnStartup(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.