Skip to content

Commit e5c180e

Browse files
committed
Initial (working)
1 parent 8285d60 commit e5c180e

54 files changed

Lines changed: 71186 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source/IdentityServer3.Contrib.Localization.UI/obj/
2+
source/IdentityServer3.Contrib.Localization.UI/bin/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# IdentityServer3.Contrib.Localization.UI
2+
Localize the UI of IdentityServer3
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer3.Contrib.Localization.UI", "IdentityServer3.Contrib.Localization.UI\IdentityServer3.Contrib.Localization.UI.csproj", "{3CF5C3ED-1E83-4C5C-AD32-CBA295BA0B78}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B72A9D2E-1290-4089-BFBF-980CDA1A802B}"
9+
ProjectSection(SolutionItems) = preProject
10+
paket.dependencies = paket.dependencies
11+
EndProjectSection
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|Any CPU = Debug|Any CPU
16+
Release|Any CPU = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{3CF5C3ED-1E83-4C5C-AD32-CBA295BA0B78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{3CF5C3ED-1E83-4C5C-AD32-CBA295BA0B78}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{3CF5C3ED-1E83-4C5C-AD32-CBA295BA0B78}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{3CF5C3ED-1E83-4C5C-AD32-CBA295BA0B78}.Release|Any CPU.Build.0 = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(SolutionProperties) = preSolution
25+
HideSolutionNode = FALSE
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{3CF5C3ED-1E83-4C5C-AD32-CBA295BA0B78}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>IdentityServer3.Contrib.Localization.UI</RootNamespace>
11+
<AssemblyName>IdentityServer3.Contrib.Localization.UI</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Xml.Linq" />
36+
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Xml" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="LocalizedViewLoader.cs" />
43+
<Compile Include="Properties\AssemblyInfo.cs" />
44+
<Compile Include="TranslatorHelper.cs" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Content Include="assets\checksession.html">
48+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
49+
</Content>
50+
<Content Include="assets\_consent.html">
51+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
52+
</Content>
53+
<Content Include="assets\_error.html">
54+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
55+
</Content>
56+
<Content Include="assets\FormPostResponse.html">
57+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58+
</Content>
59+
<Content Include="assets\layout.html">
60+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
61+
</Content>
62+
<Content Include="assets\_loggedOut.html">
63+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
64+
</Content>
65+
<Content Include="assets\_login.html">
66+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
67+
</Content>
68+
<Content Include="assets\_logout.html">
69+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
70+
</Content>
71+
<Content Include="assets\_permissions.html">
72+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
73+
</Content>
74+
<Content Include="assets\welcome.html">
75+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
76+
</Content>
77+
</ItemGroup>
78+
<ItemGroup>
79+
<None Include="IdentityServer3.Contrib.Localization.UI.csproj.paket.references" />
80+
<None Include="Resources\de.po">
81+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82+
</None>
83+
<None Include="Resources\en.po">
84+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
85+
</None>
86+
</ItemGroup>
87+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
88+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
89+
Other similar extension points exist, see Microsoft.Common.targets.
90+
<Target Name="BeforeBuild">
91+
</Target>
92+
<Target Name="AfterBuild">
93+
</Target>
94+
-->
95+
<Choose>
96+
<When Condition="$(TargetFrameworkIdentifier) == '.NETCore'">
97+
<ItemGroup>
98+
<Reference Include="Newtonsoft.Json">
99+
<HintPath>..\packages\Newtonsoft.Json\lib\netcore45\Newtonsoft.Json.dll</HintPath>
100+
<Private>True</Private>
101+
<Paket>True</Paket>
102+
</Reference>
103+
</ItemGroup>
104+
</When>
105+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
106+
<ItemGroup>
107+
<Reference Include="Newtonsoft.Json">
108+
<HintPath>..\packages\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll</HintPath>
109+
<Private>True</Private>
110+
<Paket>True</Paket>
111+
</Reference>
112+
</ItemGroup>
113+
</When>
114+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v3.0')">
115+
<ItemGroup>
116+
<Reference Include="Newtonsoft.Json">
117+
<HintPath>..\packages\Newtonsoft.Json\lib\net20\Newtonsoft.Json.dll</HintPath>
118+
<Private>True</Private>
119+
<Paket>True</Paket>
120+
</Reference>
121+
</ItemGroup>
122+
</When>
123+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
124+
<ItemGroup>
125+
<Reference Include="Newtonsoft.Json">
126+
<HintPath>..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll</HintPath>
127+
<Private>True</Private>
128+
<Paket>True</Paket>
129+
</Reference>
130+
</ItemGroup>
131+
</When>
132+
<When Condition="($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch')">
133+
<ItemGroup>
134+
<Reference Include="Newtonsoft.Json">
135+
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
136+
<Private>True</Private>
137+
<Paket>True</Paket>
138+
</Reference>
139+
</ItemGroup>
140+
</When>
141+
<When Condition="($(TargetFrameworkIdentifier) == 'Silverlight' And $(TargetFrameworkVersion) == 'v5.0') Or ($(TargetFrameworkProfile) == 'Profile5') Or ($(TargetFrameworkProfile) == 'Profile6') Or ($(TargetFrameworkProfile) == 'Profile14') Or ($(TargetFrameworkProfile) == 'Profile19') Or ($(TargetFrameworkProfile) == 'Profile24') Or ($(TargetFrameworkProfile) == 'Profile37') Or ($(TargetFrameworkProfile) == 'Profile42') Or ($(TargetFrameworkProfile) == 'Profile47') Or ($(TargetFrameworkProfile) == 'Profile92') Or ($(TargetFrameworkProfile) == 'Profile102') Or ($(TargetFrameworkProfile) == 'Profile136') Or ($(TargetFrameworkProfile) == 'Profile147') Or ($(TargetFrameworkProfile) == 'Profile158') Or ($(TargetFrameworkProfile) == 'Profile225') Or ($(TargetFrameworkProfile) == 'Profile240') Or ($(TargetFrameworkProfile) == 'Profile255') Or ($(TargetFrameworkProfile) == 'Profile328') Or ($(TargetFrameworkProfile) == 'Profile336') Or ($(TargetFrameworkProfile) == 'Profile344')">
142+
<ItemGroup>
143+
<Reference Include="Newtonsoft.Json">
144+
<HintPath>..\packages\Newtonsoft.Json\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
145+
<Private>True</Private>
146+
<Paket>True</Paket>
147+
</Reference>
148+
</ItemGroup>
149+
</When>
150+
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkIdentifier) == 'WindowsPhone' And ($(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1')) Or ($(TargetFrameworkProfile) == 'Profile7') Or ($(TargetFrameworkProfile) == 'Profile31') Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkProfile) == 'Profile44') Or ($(TargetFrameworkProfile) == 'Profile49') Or ($(TargetFrameworkProfile) == 'Profile78') Or ($(TargetFrameworkProfile) == 'Profile84') Or ($(TargetFrameworkProfile) == 'Profile111') Or ($(TargetFrameworkProfile) == 'Profile151') Or ($(TargetFrameworkProfile) == 'Profile157') Or ($(TargetFrameworkProfile) == 'Profile259')">
151+
<ItemGroup>
152+
<Reference Include="Newtonsoft.Json">
153+
<HintPath>..\packages\Newtonsoft.Json\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Newtonsoft.Json.dll</HintPath>
154+
<Private>True</Private>
155+
<Paket>True</Paket>
156+
</Reference>
157+
</ItemGroup>
158+
</When>
159+
</Choose>
160+
<Choose>
161+
<When Condition="($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch')">
162+
<ItemGroup>
163+
<Reference Include="Owin">
164+
<HintPath>..\packages\Owin\lib\net40\Owin.dll</HintPath>
165+
<Private>True</Private>
166+
<Paket>True</Paket>
167+
</Reference>
168+
</ItemGroup>
169+
</When>
170+
</Choose>
171+
<Choose>
172+
<When Condition="($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v3.5' Or $(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch')">
173+
<ItemGroup>
174+
<Reference Include="SecondLanguage">
175+
<HintPath>..\packages\SecondLanguage\lib\net35\SecondLanguage.dll</HintPath>
176+
<Private>True</Private>
177+
<Paket>True</Paket>
178+
</Reference>
179+
</ItemGroup>
180+
</When>
181+
</Choose>
182+
<Choose>
183+
<When Condition="($(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch')">
184+
<ItemGroup>
185+
<Reference Include="Thinktecture.IdentityServer3">
186+
<HintPath>..\packages\Thinktecture.IdentityServer3\lib\net45\Thinktecture.IdentityServer3.dll</HintPath>
187+
<Private>True</Private>
188+
<Paket>True</Paket>
189+
</Reference>
190+
</ItemGroup>
191+
</When>
192+
</Choose>
193+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Thinktecture.IdentityServer3
2+
SecondLanguage
3+
Newtonsoft.Json
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Text.RegularExpressions;
5+
using Thinktecture.IdentityServer.Core.Services.Default;
6+
7+
namespace IdentityServer3.Contrib.Localization.UI
8+
{
9+
public class LocalizedViewLoader : IViewLoader
10+
{
11+
readonly FileSystemViewLoader file;
12+
readonly EmbeddedAssetsViewLoader embedded;
13+
14+
public LocalizedViewLoader()
15+
: this(GetDefaultDirectory())
16+
{
17+
}
18+
19+
public LocalizedViewLoader(string directory)
20+
{
21+
file = new FileSystemViewLoader(directory);
22+
embedded = new EmbeddedAssetsViewLoader();
23+
}
24+
25+
static string GetDefaultDirectory()
26+
{
27+
var path = AppDomain.CurrentDomain.BaseDirectory;
28+
path = Path.Combine(path, "assets");
29+
return path;
30+
}
31+
32+
public string Load(string name)
33+
{
34+
var value = file.Load(name);
35+
if (value == null)
36+
{
37+
value = embedded.Load(name);
38+
}
39+
return Translate(value);
40+
}
41+
42+
private string Translate(string html)
43+
{
44+
var translator = TranslatorHelper.Instance.GetTranslatorForCurrentCulture();
45+
const string pattern = @"\[\[(\S+)\]\]";
46+
var matches =
47+
from Match match in Regex.Matches(html, pattern)
48+
select match.Groups[1].Value;
49+
50+
foreach (var match in matches)
51+
{
52+
var translated = translator.Translate(match);
53+
html = html.Replace("[[" + match + "]]", translated);
54+
}
55+
return html;
56+
}
57+
}
58+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("IdentityServer3.Contrib.Localization.UI")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("IdentityServer3.Contrib.Localization.UI")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("90cd82eb-529b-49a9-bcda-f7c5403c570a")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)