@@ -68,7 +68,7 @@ func downloadTranslation(languageCode: String, folderName: String) {
6868
6969 jsonDict. forEach ( { ( key: String , value: Any ) in
7070
71- guard let index = key. index ( of: Character ( UnicodeScalar ( 0004 ) ) ) else {
71+ guard let index = key. firstIndex ( of: Character ( UnicodeScalar ( 0004 ) ) ) else {
7272 return
7373 }
7474
@@ -105,22 +105,20 @@ func downloadTranslation(languageCode: String, folderName: String) {
105105 let fileManager = FileManager . default
106106 try ? fileManager. createDirectory ( atPath: languageFolder, withIntermediateDirectories: true , attributes: nil )
107107
108- /// This sort of hack-ey – we're not actually downloading anything here, but the idea is
109- /// to keep all of the metadata generation code in the same place. By keeping this in the
110- /// same file, it should be easier to find, and update if necessary.
111- let marketingURL = " https://woocommerce.com/mobile/ "
112108
113109 do {
110+ let releaseNotesPath = " \( languageFolder) /release_notes.txt "
111+
112+ /// Remove existing release notes in case they weren't translated for this release (that way `deliver` will fall back to the `default` locale)
113+ if FileManager . default. fileExists ( atPath: releaseNotesPath) {
114+ try FileManager . default. removeItem ( at: URL ( fileURLWithPath: releaseNotesPath) )
115+ }
116+
114117 try subtitle? . write ( toFile: " \( languageFolder) /subtitle.txt " , atomically: true , encoding: . utf8)
115- try whatsNew? . write ( toFile: " \( languageFolder ) /release_notes.txt " , atomically: true , encoding: . utf8)
118+ try whatsNew? . write ( toFile: releaseNotesPath , atomically: true , encoding: . utf8)
116119 try keywords? . write ( toFile: " \( languageFolder) /keywords.txt " , atomically: true , encoding: . utf8)
117120 try storeDescription? . write ( toFile: " \( languageFolder) /description.txt " , atomically: true , encoding: . utf8)
118121 try promoText? . write ( toFile: " \( languageFolder) /promotional_text.txt " , atomically: true , encoding: . utf8)
119-
120- // Don't add the marketing URL unless there's other metadata that's been downloaded
121- if try fileManager. contentsOfDirectory ( atPath: languageFolder) . count > 0 {
122- try marketingURL. write ( toFile: " \( languageFolder) /marketing_url.txt " , atomically: true , encoding: . utf8)
123- }
124122 } catch {
125123 print ( " Error writing: \( error) " )
126124 }
@@ -130,16 +128,6 @@ func downloadTranslation(languageCode: String, folderName: String) {
130128 sema. wait ( )
131129}
132130
133- func deleteExistingMetadata( ) {
134- let fileManager = FileManager . default
135- let url = URL ( fileURLWithPath: baseFolder, isDirectory: true )
136- try ? fileManager. removeItem ( at: url)
137- try ? fileManager. createDirectory ( at: url, withIntermediateDirectories: false )
138- }
139-
140-
141- deleteExistingMetadata ( )
142-
143131languages. forEach ( { ( key: String , value: String ) in
144132 downloadTranslation ( languageCode: value, folderName: key)
145133} )
0 commit comments