forked from mdibaiee/node-games
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from CamilaSosa96/develop
Language system with spanish translation
- Loading branch information
Showing
5 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class LanguageSystem{ | ||
constructor(_language = undefined){ | ||
this.language = _language; | ||
} | ||
|
||
translate(text){ | ||
if(this.language === 'es'){ | ||
return this.spanishTranslator(text); | ||
} | ||
return text; | ||
} | ||
|
||
spanishTranslator(text){ | ||
if(text === 'Score: '){ | ||
return 'Puntaje: '; | ||
} | ||
if(text === 'Game Over!'){ | ||
return 'Fin del juego!'; | ||
} | ||
if(text === 'Press any key to play again'){ | ||
return 'Presione cualquier tecla para jugar nuevamente'; | ||
} | ||
if(text === 'Player '){ | ||
return 'Jugador '; | ||
} | ||
if(text === ' won!'){ | ||
return ' ganó!'; | ||
} | ||
if(text === 'Health: '){ | ||
return 'Vida: '; | ||
} | ||
if(text === 'Angle: '){ | ||
return 'Ángulo: '; | ||
} | ||
return text; | ||
} | ||
} | ||
|
||
module.exports = LanguageSystem; |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
#!/usr/bin/env node | ||
const LanguageSystem = require('./build/classes/languageSystem') | ||
|
||
var game = process.argv[2]; | ||
var language = process.argv[3]; | ||
|
||
if (!game) { | ||
console.log('usage: node-games <game>'); | ||
console.log('usage: node-games <game> <language>'); | ||
console.log(''); | ||
console.log('Games'); | ||
console.log('- spacecraft'); | ||
console.log('- snake'); | ||
console.log('- tanks'); | ||
console.log(''); | ||
console.log('Languages'); | ||
console.log('- NO PARAM : English (Default)'); | ||
console.log('- es : Español'); | ||
return; | ||
} | ||
|
||
global.translator = new LanguageSystem(language); | ||
|
||
require('babel-polyfill'); | ||
|
||
require(__dirname + '/build/' + game); | ||
require(__dirname + '/build/' + game); |