@@ -13,8 +13,6 @@ public interface IUnfoldTranslator
1313 {
1414 bool IsInitialized ( ) ;
1515 string TranslateUnfold ( DescribeUnfold u ) ;
16-
17-
1816 }
1917 public class UnfoldTranslator : IUnfoldTranslator
2018 {
@@ -27,7 +25,8 @@ public class UnfoldTranslator : IUnfoldTranslator
2725 static string emptyItemTemplate ;
2826 static string commentItemTemplate ;
2927 static string coloredItemTemplate ;
30- static string prodTemplate ;
28+ static string productionTemplate ;
29+ static string coloredProductionTemplate ;
3130 static string linkTemplate ;
3231
3332 public UnfoldTranslator ( string template = null )
@@ -58,8 +57,10 @@ public UnfoldTranslator(string template = null)
5857 pageTemplate = File . ReadAllText ( finfo . FullName ) ;
5958 else if ( finfo . Name . StartsWith ( "Root" ) )
6059 rootTemplate = File . ReadAllText ( finfo . FullName ) ;
60+ else if ( finfo . Name . StartsWith ( "ProductionColored" ) )
61+ coloredProductionTemplate = File . ReadAllText ( finfo . FullName ) ;
6162 else if ( finfo . Name . StartsWith ( "Production" ) )
62- prodTemplate = File . ReadAllText ( finfo . FullName ) ;
63+ productionTemplate = File . ReadAllText ( finfo . FullName ) ;
6364 else if ( finfo . Name . StartsWith ( "ItemEmpty" ) )
6465 emptyItemTemplate = File . ReadAllText ( finfo . FullName ) ;
6566 else if ( finfo . Name . StartsWith ( "ItemComment" ) )
@@ -84,7 +85,12 @@ public UnfoldTranslator(string template = null)
8485 LogError ( "No \" Root\" Template found during translation." ) ;
8586 flag = true ;
8687 }
87- if ( prodTemplate == null )
88+ if ( coloredProductionTemplate == null )
89+ {
90+ LogError ( "No \" ProductionColored\" Template found during translation." ) ;
91+ flag = true ;
92+ }
93+ if ( productionTemplate == null )
8894 {
8995 LogError ( "No \" Production\" Template found during translation." ) ;
9096 flag = true ;
@@ -128,7 +134,9 @@ public UnfoldTranslator(string template = null)
128134 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Page" ) ;
129135 rootTemplate =
130136 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Root" ) ;
131- prodTemplate =
137+ coloredProductionTemplate =
138+ ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"ProductionColored" ) ;
139+ productionTemplate =
132140 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Production" ) ;
133141 itemTemplate =
134142 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Item" ) ;
@@ -184,8 +192,10 @@ public UnfoldTranslator(
184192 pageTemplate = File . ReadAllText ( finfo . FullName ) ;
185193 else if ( finfo . Name . StartsWith ( "Root" ) )
186194 rootTemplate = File . ReadAllText ( finfo . FullName ) ;
195+ else if ( finfo . Name . StartsWith ( "ProductionColored" ) )
196+ coloredProductionTemplate = File . ReadAllText ( finfo . FullName ) ;
187197 else if ( finfo . Name . StartsWith ( "Production" ) )
188- prodTemplate = File . ReadAllText ( finfo . FullName ) ;
198+ productionTemplate = File . ReadAllText ( finfo . FullName ) ;
189199 else if ( finfo . Name . StartsWith ( "ItemEmpty" ) )
190200 emptyItemTemplate = File . ReadAllText ( finfo . FullName ) ;
191201 else if ( finfo . Name . StartsWith ( "ItemComment" ) )
@@ -210,7 +220,12 @@ public UnfoldTranslator(
210220 LogError ( "No \" Root\" Template found during translation." ) ;
211221 flag = true ;
212222 }
213- if ( prodTemplate == null )
223+ if ( coloredProductionTemplate == null )
224+ {
225+ LogError ( "No \" ProductionColored\" Template found during translation." ) ;
226+ flag = true ;
227+ }
228+ if ( productionTemplate == null )
214229 {
215230 LogError ( "No \" Production\" Template found during translation." ) ;
216231 flag = true ;
@@ -254,7 +269,9 @@ public UnfoldTranslator(
254269 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Page" ) ;
255270 rootTemplate =
256271 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Root" ) ;
257- prodTemplate =
272+ coloredProductionTemplate =
273+ ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"ProductionColored" ) ;
274+ productionTemplate =
258275 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Production" ) ;
259276 itemTemplate =
260277 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Item" ) ;
@@ -313,8 +330,10 @@ public UnfoldTranslator(
313330 pageTemplate = File . ReadAllText ( finfo . FullName ) ;
314331 else if ( finfo . Name . StartsWith ( "Root" ) )
315332 rootTemplate = File . ReadAllText ( finfo . FullName ) ;
333+ else if ( finfo . Name . StartsWith ( "ProductionColored" ) )
334+ coloredProductionTemplate = File . ReadAllText ( finfo . FullName ) ;
316335 else if ( finfo . Name . StartsWith ( "Production" ) )
317- prodTemplate = File . ReadAllText ( finfo . FullName ) ;
336+ productionTemplate = File . ReadAllText ( finfo . FullName ) ;
318337 else if ( finfo . Name . StartsWith ( "ItemEmpty" ) )
319338 emptyItemTemplate = File . ReadAllText ( finfo . FullName ) ;
320339 else if ( finfo . Name . StartsWith ( "ItemComment" ) )
@@ -339,7 +358,12 @@ public UnfoldTranslator(
339358 LogError ( "No \" Root\" Template found during translation." ) ;
340359 flag = true ;
341360 }
342- if ( prodTemplate == null )
361+ if ( coloredProductionTemplate == null )
362+ {
363+ LogError ( "No \" ProductionColored\" Template found during translation." ) ;
364+ flag = true ;
365+ }
366+ if ( productionTemplate == null )
343367 {
344368 LogError ( "No \" Production\" Template found during translation." ) ;
345369 flag = true ;
@@ -383,7 +407,9 @@ public UnfoldTranslator(
383407 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Page" ) ;
384408 rootTemplate =
385409 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Root" ) ;
386- prodTemplate =
410+ coloredProductionTemplate =
411+ ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"ProductionColored" ) ;
412+ productionTemplate =
387413 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Production" ) ;
388414 itemTemplate =
389415 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Item" ) ;
@@ -444,8 +470,10 @@ public UnfoldTranslator(
444470 pageTemplate = File . ReadAllText ( finfo . FullName ) ;
445471 else if ( finfo . Name . StartsWith ( "Root" ) )
446472 rootTemplate = File . ReadAllText ( finfo . FullName ) ;
473+ else if ( finfo . Name . StartsWith ( "ProductionColored" ) )
474+ coloredProductionTemplate = File . ReadAllText ( finfo . FullName ) ;
447475 else if ( finfo . Name . StartsWith ( "Production" ) )
448- prodTemplate = File . ReadAllText ( finfo . FullName ) ;
476+ productionTemplate = File . ReadAllText ( finfo . FullName ) ;
449477 else if ( finfo . Name . StartsWith ( "ItemEmpty" ) )
450478 emptyItemTemplate = File . ReadAllText ( finfo . FullName ) ;
451479 else if ( finfo . Name . StartsWith ( "ItemComment" ) )
@@ -470,7 +498,12 @@ public UnfoldTranslator(
470498 LogError ( "No \" Root\" Template found during translation." ) ;
471499 flag = true ;
472500 }
473- if ( prodTemplate == null )
501+ if ( coloredProductionTemplate == null )
502+ {
503+ LogError ( "No \" ProductionColored\" Template found during translation." ) ;
504+ flag = true ;
505+ }
506+ if ( productionTemplate == null )
474507 {
475508 LogError ( "No \" Production\" Template found during translation." ) ;
476509 flag = true ;
@@ -514,7 +547,9 @@ public UnfoldTranslator(
514547 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Page" ) ;
515548 rootTemplate =
516549 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Root" ) ;
517- prodTemplate =
550+ coloredProductionTemplate =
551+ ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"ProductionColored" ) ;
552+ productionTemplate =
518553 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Production" ) ;
519554 itemTemplate =
520555 ResourceUtil . ExtractResourceByFileName_String ( selectedTemplate , @"Item" ) ;
@@ -797,7 +832,22 @@ string TranslateProduction(DescribeUnfold u, string id)
797832 }
798833
799834 //replace in template
800- string pt = prodTemplate . Replace ( "{TITLE}" , u . Translations [ id ] + linkage ) ;
835+ if ( u . Decorators . ContainsKey ( id ) )
836+ {
837+ List < string > decorators = u . Decorators [ id ] ;
838+ foreach ( string s in decorators )
839+ {
840+ if ( s . StartsWith ( "color|" ) )
841+ {
842+ string val = s . Substring ( 6 ) ;
843+ string res = coloredProductionTemplate . Replace ( "{TITLE}" , u . Translations [ id ] + linkage ) ;
844+ res = res . Replace ( "{COLOR}" , val ) ;
845+ res = res . Replace ( "{ITEMS}" , items ) ;
846+ return res ;
847+ }
848+ }
849+ }
850+ string pt = productionTemplate . Replace ( "{TITLE}" , u . Translations [ id ] + linkage ) ;
801851 pt = pt . Replace ( "{ITEMS}" , items ) ;
802852 return pt ;
803853 }
0 commit comments