Stebann is right, translating is not providing the exact same words from one language into another language. Translating is conveying the meaning (what some call "spirit") of the message into the other language which sometimes implies forgetting words, tenses or complete structures in order to preserve the real meaning. For example:
It is better to be king in hell than servant in heaven
Mejor ser cabeza de ratón que cola de león (it is better to be a mouse's head than a lion's tail).
My dog is too wounded, I will have to put him to sleep.
Mi perro está demasiado herido, tendré que sacrificarlo.
(My dog is too wounded, I will have to sacrifice him).
I wonder who knows?
¿Quién sabrá?
(Who will know?)
In the case of your sentence, though Stebann's sentences are correct, the most natural ways of saying it would be:
La única manera de fallar es darse por vencido.
(The only way of failing is giving up).
or
El fracazo sólo se da cuando nos damos por vencidos.
(Failing only occurs when we give up).
I hope this helps.