@@ -60,7 +60,7 @@ struct StringsGenerator: Generator {
6060 // Maybe when we pick up this issue: https://github.com/mac-cain13/R.swift/issues/136
6161 private static func computeParams( filename: String , strings: [ LocalizableStrings ] ) -> [ StringValues ] {
6262
63- var allParams : [ String : [ ( Locale , String , [ StringParam ] ) ] ] = [ : ]
63+ var allParams : [ String : [ ( Locale , LocalizableStrings . Entry ) ] ] = [ : ]
6464 let baseKeys : Set < String > ?
6565 let bases = strings. filter { $0. locale. isBase }
6666 if bases. isEmpty {
@@ -95,10 +95,10 @@ struct StringsGenerator: Generator {
9595 for key in groupedKeys. uniques {
9696 if let entry = byKey [ key] {
9797 if let _ = allParams [ key] {
98- allParams [ key] ? . append ( ( ls. locale, entry. val , entry . params ) )
98+ allParams [ key] ? . append ( ( ls. locale, entry) )
9999 }
100100 else {
101- allParams [ key] = [ ( ls. locale, entry. val , entry . params ) ]
101+ allParams [ key] = [ ( ls. locale, entry) ]
102102 }
103103 }
104104 }
@@ -138,8 +138,8 @@ struct StringsGenerator: Generator {
138138 var params : [ StringParam ] = [ ]
139139 var areCorrectFormatSpecifiers = true
140140
141- for (locale, _ , ps ) in keyParams {
142- if ps . any ( { $0. spec == FormatSpecifier . TopType } ) {
141+ for (locale, entry ) in keyParams {
142+ if entry . params . any ( { $0. spec == FormatSpecifier . TopType } ) {
143143 let name = locale. withFilename ( filename)
144144 warn ( " Skipping string \( key) in \( name) , not all format specifiers are consecutive " )
145145
@@ -149,8 +149,8 @@ struct StringsGenerator: Generator {
149149
150150 if !areCorrectFormatSpecifiers { continue }
151151
152- for (_, _ , ps ) in keyParams {
153- if let unified = params. unify ( ps ) {
152+ for (_, entry ) in keyParams {
153+ if let unified = params. unify ( entry . params ) {
154154 params = unified
155155 }
156156 else {
@@ -162,8 +162,9 @@ struct StringsGenerator: Generator {
162162
163163 if !areCorrectFormatSpecifiers { continue }
164164
165- let vals = keyParams. map { ( $0. 0 , $0. 1 ) }
166- let values = StringValues ( key: key, params: params, tableName: filename, values: vals )
165+ let vals = keyParams. map { locale, entry in ( locale, entry. val) }
166+ let comments = keyParams. map { locale, entry in ( locale, entry. comment) }
167+ let values = StringValues ( key: key, params: params, tableName: filename, values: vals, entryComments: comments)
167168 results. append ( values)
168169 }
169170
@@ -273,6 +274,7 @@ private struct StringValues {
273274 let params : [ StringParam ]
274275 let tableName : String
275276 let values : [ ( Locale , String ) ]
277+ let entryComments : [ ( Locale , String ? ) ]
276278
277279 var localizedString : String {
278280 let escapedKey = key. escapedStringLiteral
@@ -317,6 +319,22 @@ private struct StringValues {
317319 let locales = values. flatMap { $0. 0 . localeDescription }
318320 results. append ( " Locales: \( locales. joinWithSeparator ( " , " ) ) " )
319321 }
322+
323+ let baseEntryComment = entryComments. filter { $0. 0 . isBase } . flatMap { $0. 1 } . first
324+ if let baseEntryComment = baseEntryComment {
325+ if !results. isEmpty {
326+ results. append ( " " )
327+ }
328+
329+ let lines = baseEntryComment. componentsSeparatedByString ( " \n " )
330+ if lines. count == 1 {
331+ results. append ( " Comment: \( lines [ 0 ] ) " )
332+ } else {
333+ results. append ( " Comment: " )
334+ let indented = lines. map { " \( $0) " }
335+ results. appendContentsOf ( indented)
336+ }
337+ }
320338
321339 return results
322340 }
0 commit comments