Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function translate(language, code)
- local translations;
- if language == "javascript" or language == "js" then
- translations = {
- ["var"] = "local",
- ["(%a+)%s*%+%+"] = "%1 = %1 + 1",
- ["(%a+)%s*%+%=%s*(" .. patterns.number .. ")"] = "%1 = %1 + %2",
- ["(%a+)%s*%-%-"] = "%1 = %1 - 1",
- ["function%s+(%a+)%s*%((.+)%)%s*{"] = "function %1(%2)",
- ["while%s*%((.+)%)%s*{"] = "while %1 do",
- ["(function%s+%a+%s*%(.+%).+)}"] = "%1 end",
- ["([while]?[if]?)(.+)([do]?[then]?)(.+)}"] = "%1 %2 %3 %4 end",
- ["console%.log"] = "print"
- }
- end
- for pattern, replace in pairs(translations) do
- code = code:gsub(pattern, replace)
- end
- return code
- end
Advertisement
Add Comment
Please, Sign In to add comment