Skip to content

Commit

Permalink
add "fi" as translation srclang (old-code-commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
thejh committed Nov 19, 2011
1 parent 8863123 commit ffcbc1b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bot.coffee
Expand Up @@ -438,15 +438,19 @@ commands =
else
return reply "error: #{err}", error: true
translate: (message, [srclang, dstlang, word], reply) ->
return (reply "that srclang (#{srclang}) isnt supported", error: true) if srclang isnt 'de' and srclang isnt 'en'
return (reply "that srclang (#{srclang}) isnt supported", error: true) if srclang isnt 'de' and srclang isnt 'en' and srclang isnt 'fi'
reqopts =
uri: "http://#{srclang}.wiktionary.org/w/index.php?action=raw&title=#{encodeURIComponent word}"
headers: wpheaders
request reqopts, (err, response, body) ->
console.log "TRANSLATE ERR <<<"+err+">>>" if err
return (reply 'error in "translate"', error: true) if err or not body
hits = []
body.replace /{{(Ü|t|t\+|t-)\|([^|]+)\|([^}]+)}}/g, (_, _, curDst, translation) ->
translateRegex = if srclang is 'fi'
/\*({{)([^}]+)}}: \[\[([^\]]+)]/g
else
/{{(Ü|t|t\+|t-)\|([^|]+)\|([^}]+)}}/g
body.replace translateRegex, (_, _, curDst, translation) ->
return unless curDst is dstlang
return if -1 isnt translation.indexOf '\n'
return if -1 isnt translation.indexOf '\r'
Expand Down

0 comments on commit ffcbc1b

Please sign in to comment.