Created
July 17, 2018 19:07
-
-
Save Leowbattle/6514bbad97f67a4d3adb646169675f5e to your computer and use it in GitHub Desktop.
Turn C code into Spanish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ARGV.length == 0 | |
puts "Usage: ruby esc.rb [filename]" | |
exit | |
end | |
prog = File.read ARGV[0] | |
prog = prog.gsub(/auto/, "automático") | |
prog = prog.gsub(/const/, "constante") | |
prog = prog.gsub(/double/, "doble"); | |
prog = prog.gsub(/float/, "flotador") | |
prog = prog.gsub(/int/, "entero") | |
prog = prog.gsub(/float/, "flotador") | |
prog = prog.gsub(/short/, "corto") | |
prog = prog.gsub(/struct/, "estructura") | |
prog = prog.gsub(/unsigned/, "no firmado") | |
prog = prog.gsub(/break/, "descanso") | |
prog = prog.gsub(/continue/, "continuar") | |
prog = prog.gsub(/else/, "más") | |
prog = prog.gsub(/for/, "para") | |
prog = prog.gsub(/long/, "largo") | |
prog = prog.gsub(/signed/, "firmado") | |
prog = prog.gsub(/switch/, "cambiar") | |
prog = prog.gsub(/void/, "vacío") | |
prog = prog.gsub(/case/, "caso") | |
prog = prog.gsub(/default/, "defecto") | |
prog = prog.gsub(/long/, "largo") | |
prog = prog.gsub(/enum/, "enumeración") | |
prog = prog.gsub(/goto/, "ir") | |
prog = prog.gsub(/register/, "registro") | |
prog = prog.gsub(/sizeof/, "tamaño de") | |
prog = prog.gsub(/typedef/, "definición de tipo") | |
prog = prog.gsub(/volatile/, "volátil") | |
prog = prog.gsub(/char/, "carta") | |
prog = prog.gsub(/do/, "hacer") | |
prog = prog.gsub(/extern/, "externo") | |
prog = prog.gsub(/if/, "si") | |
prog = prog.gsub(/return/, "regreso") | |
prog = prog.gsub(/static/, "estático") | |
prog = prog.gsub(/union/, "unión") | |
prog = prog.gsub(/while/, "mientras") | |
prog = prog.gsub(/true/, "cierto") | |
prog = prog.gsub(/false/, "falso") | |
prog = prog.gsub(/NULL/, "NULO") | |
prog = prog.gsub(/include/, "incluir") | |
prog = prog.gsub(/define/, "definir") | |
# error is a cognate | |
prog = prog.gsub(/pragma/, "pragmático") | |
prog = prog.gsub(/endif/, "terminara si") | |
prog = prog.gsub(/elif/, "de lo contrario si") | |
prog = prog.gsub(/ifdef/, "si está definido") | |
prog = prog.gsub(/undef/, "indefinir") | |
prog = prog.gsub(/line/, "línea") | |
prog = prog.gsub(/warning/, "advertencia") | |
puts prog | |
File.truncate(ARGV[0], 0) | |
File.open(ARGV[0], "r+").puts prog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment