mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-22 10:55:19 -04:00
Fix issue #1472
This commit is contained in:
parent
4f2daf1a1d
commit
71569d61e0
1 changed files with 15 additions and 1 deletions
|
@ -1,5 +1,16 @@
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
en = require('../app/locale/en').translation
|
||||
|
||||
en_source = fs.readFileSync(path.join(__dirname, '../app/locale/en.coffee'), encoding='utf8')
|
||||
comments_map = {}
|
||||
|
||||
comment_pattern = /^[\s\n]*([^:\n]+):\s*"[^#\n"]+"\s*#(.*)$/gm
|
||||
|
||||
comment = []
|
||||
while (comment = comment_pattern.exec en_source)?
|
||||
comments_map[comment[1]] = comment[2]
|
||||
|
||||
dir = fs.readdirSync 'app/locale'
|
||||
for file in dir when not (file in ['locale.coffee', 'en.coffee'])
|
||||
contents = require('../app/locale/' + file)
|
||||
|
@ -16,6 +27,9 @@ for file in dir when not (file in ['locale.coffee', 'en.coffee'])
|
|||
tagMissing = not cat[enTag]?
|
||||
tag = (cat[enTag] ?= enString)
|
||||
tag = tag.replace /"/g, '\\"'
|
||||
lines.push "#{if tagMissing then '#' else ''} #{enTag}: \"#{tag}\""
|
||||
comment = ""
|
||||
comment = " \##{comments_map[enTag]}" if comments_map[enTag]?
|
||||
|
||||
lines.push "#{if tagMissing then '#' else ''} #{enTag}: \"#{tag}\"#{comment}"
|
||||
newContents = lines.join('\n') + '\n'
|
||||
fs.writeFileSync 'app/locale/' + file, newContents
|
||||
|
|
Loading…
Reference in a new issue