This commit is contained in:
David Beckley 2014-09-19 18:34:11 -07:00
parent 4f2daf1a1d
commit 71569d61e0

View file

@ -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