Add i18n and es/en locale
This commit is contained in:
@@ -49,7 +49,7 @@ function loop() {
|
||||
gameover();
|
||||
}
|
||||
|
||||
ui.cursor.goto(0, 0).yellow().write(`Score: ${score}`);
|
||||
ui.cursor.goto(0, 0).yellow().write(`${i18n.__('Score')}: ${score}`);
|
||||
ui.cursor.reset();
|
||||
|
||||
setTimeout(loop, FRAME);
|
||||
@@ -147,7 +147,7 @@ function createPart() {
|
||||
}
|
||||
|
||||
function gameover() {
|
||||
const MSG = 'Game Over!';
|
||||
const MSG = i18n.__('Game Over');
|
||||
ui.cursor.goto(ui.center.x - MSG.length / 2, ui.center.y);
|
||||
ui.cursor.red();
|
||||
ui.cursor.bold();
|
||||
@@ -155,7 +155,7 @@ function gameover() {
|
||||
|
||||
ui.cursor.reset();
|
||||
ui.cursor.hex('#f65590');
|
||||
const RETRY = 'Press any key to play again';
|
||||
const RETRY = i18n.__('Press any key to play again');
|
||||
ui.cursor.goto(ui.center.x - RETRY.length / 2, ui.center.y + 2);
|
||||
ui.write(RETRY);
|
||||
|
||||
|
@@ -59,7 +59,7 @@ setInterval(() => {
|
||||
if (enemy.killed < 3) enemy.killed++;
|
||||
})
|
||||
|
||||
ui.cursor.goto(0, 0).yellow().write(`Score: ${score}`);
|
||||
ui.cursor.goto(0, 0).yellow().write(`${i18n.__('Score')}: ${score}`);
|
||||
ui.cursor.reset();
|
||||
}, FRAME);
|
||||
|
||||
|
15
src/tanks.js
15
src/tanks.js
@@ -21,7 +21,7 @@ function loop() {
|
||||
|
||||
if (one.dead || two.dead) {
|
||||
let num = one.dead ? '2' : '1';
|
||||
const msg = `Player ${num} won!`;
|
||||
const msg = i18n.__('Player %s won!', num);
|
||||
ui.cursor.red();
|
||||
ui.cursor.bold();
|
||||
|
||||
@@ -50,12 +50,12 @@ function loop() {
|
||||
|
||||
ui.cursor.goto(0, 1);
|
||||
if (turn() === one) ui.cursor.hex('#54ffff');
|
||||
ui.write('Player 1');
|
||||
ui.write(`${i18n.__('Player')} 1`);
|
||||
ui.cursor.reset();
|
||||
ui.cursor.goto(0, 2);
|
||||
ui.write('Health: ' + one.health);
|
||||
ui.write(`${i18n.__('Health')}: ${one.health}`);
|
||||
ui.cursor.goto(0, 3);
|
||||
ui.write('Angle: ' + parseInt(one.angle));
|
||||
ui.write(`${i18n.__('Angle')}: ${parseInt(one.angle)}`);
|
||||
|
||||
two.draw();
|
||||
two.bullets.forEach((bullet, i) => {
|
||||
@@ -75,13 +75,12 @@ function loop() {
|
||||
|
||||
ui.cursor.goto(ui.output.columns - 10, 1);
|
||||
if (turn() === two) ui.cursor.hex('#54ffff');
|
||||
ui.write('Player 2');
|
||||
ui.write(`${i18n.__('Player')} 2`);
|
||||
ui.cursor.reset();
|
||||
ui.cursor.goto(ui.output.columns - 10, 2);
|
||||
ui.write('Health: ' + two.health);
|
||||
ui.write(`${i18n.__('Health')}: ${two.health}`);
|
||||
ui.cursor.goto(ui.output.columns - 10, 3);
|
||||
ui.write('Angle: ' + parseInt(two.angle));
|
||||
|
||||
ui.write(`${i18n.__('Angle')}: ${parseInt(two.angle)}`);
|
||||
setTimeout(loop, FRAME);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user