File tree Expand file tree Collapse file tree
source/IdentityServer3.Contrib.Localization.UI Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,23 +36,7 @@ public string Load(string name)
3636 {
3737 value = embedded . Load ( name ) ;
3838 }
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 ;
39+ return TranslatorHelper . Instance . Translate ( value ) ;
5640 }
5741 }
5842}
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Linq ;
45using System . Reflection ;
6+ using System . Text . RegularExpressions ;
57using System . Threading ;
68using SecondLanguage ;
79
@@ -79,5 +81,21 @@ private string AssemblyDirectory
7981 return Path . GetDirectoryName ( path ) ;
8082 }
8183 }
84+
85+ public string Translate ( string html )
86+ {
87+ var translator = GetTranslatorForCurrentCulture ( ) ;
88+ const string pattern = @"\[\[([a-zA-Z0-9\.]+)\]\]" ;
89+ var matches =
90+ from Match match in Regex . Matches ( html , pattern )
91+ select match . Groups [ 1 ] . Value ;
92+
93+ foreach ( var match in matches )
94+ {
95+ var translated = translator . Translate ( match ) ;
96+ html = html . Replace ( "[[" + match + "]]" , translated ) ;
97+ }
98+ return html ;
99+ }
82100 }
83101}
You can’t perform that action at this time.
0 commit comments