End of train commit
This commit is contained in:
@@ -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={}) ->
|
||||
|
||||
Reference in New Issue
Block a user