What website is it? Normally I would say that it depends on the website and the license. If the website doesn't have a license for the code, I would look into contacting whoever administrates it.
If it's just small snippets and optimizations, then it's probably fine to translate the code, provided you put some attribution.