End of train commit

This commit is contained in:
2014-07-02 12:35:48 +02:00
parent cddff247a4
commit 8ab355460c
9 changed files with 96 additions and 46 deletions
@@ -33,19 +33,22 @@
result = result.replace("%{#{variable}}", value)
isafety = 0
while result.indexOf("${") > -1
m = result.match(/\${([\w\.]+(\|\w+)?)}/)
if m[2]
translatable = m[1].replace(m[2], "")
operation = $transformation_mappings[m[2].substr(1) or m[2].substr(1)]
else
translatable = m[1]
operation = null
replacable = t(translatable)
replacable = replacable[operation]() if operation
result = result.replace(m[0], replacable)
break if isafety > 10 # referencing other translations may cause infinite loops
isafety += 1
try
while result.indexOf("${") > -1
m = result.match(/\${([\w\.]+(\|\w+)?)}/)
if m[2]
translatable = m[1].replace(m[2], "")
operation = $transformation_mappings[m[2].substr(1) or m[2].substr(1)]
else
translatable = m[1]
operation = null
replacable = t(translatable)
replacable = replacable[operation]() if operation
result = result.replace(m[0], replacable)
break if isafety > 10 # referencing other translations may cause infinite loops
isafety += 1
catch err
console.log "translation #{result} cannot be interpolated"
result
@setLocale = (locale, options={}) ->