translated game into portuagese and spanish
This commit is contained in:
20
README.md
20
README.md
@@ -1,18 +1,30 @@
|
||||
# 2020 L4 Application Programming coursework
|
||||
# Scrabble (Multiplayer)
|
||||
## 2020/21 L4 Application Programming coursework
|
||||
|
||||
SEE BELOW FOR CONFIGURATION GUIDE
|
||||
|
||||
## Product Description
|
||||
### Product Description
|
||||
|
||||
https://scrabble.hasbro.com/en-us/rules
|
||||
https://www.zapsplat.com/?s=scrabble
|
||||
|
||||
https://www.scrabble3d.info/t2342f139-Default-rules.html
|
||||
|
||||
## Configuration Guide
|
||||
|
||||
If the scope allowed for it, every function would be (reasonably) unit tested.
|
||||
|
||||
The solution to locale-ise language in HTML is extremely naive and there are a lot better ways to do it, i did what i could in the time without a full refractor and SSR.
|
||||
However it is not at much detriment of readability and maintainability of the code so i diddn't deem it neccesary.
|
||||
|
||||
The locales are stored in different language files so it is easier for people to contribute and thus more maintanable.
|
||||
|
||||
### Configuration Guide
|
||||
|
||||
|
||||
### Contributing
|
||||
|
||||
## Acknowledgements
|
||||
To contribute a translation
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
Inês Filipa Baiõa Antunes - Tranlations (Portuguese, Spanish)
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
<title>Lobby</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Game Lobby</h1>
|
||||
<script src="../locale.js"></script>
|
||||
|
||||
<h1><script>document.write(localeString('game-lobby'))</script></h1>
|
||||
|
||||
<!--TODO: Should have a disconnect button-->
|
||||
|
||||
@@ -22,9 +23,12 @@
|
||||
|
||||
|
||||
<div id="lobbies" style="display:none">
|
||||
<input type="button" value="Create Lobby" onclick="showCreateLobby()">
|
||||
<input type="button" value="Join Lobby" onclick="showJoinLobby()">
|
||||
|
||||
<script>
|
||||
document.write(`
|
||||
<input type="button" value="${localeString('lobby-create')}" onclick="showCreateLobby()">
|
||||
<input type="button" value="${localeString('lobby-join')}" onclick="showJoinLobby()">
|
||||
`);
|
||||
</script>
|
||||
<p><p>
|
||||
|
||||
<!-- <table border="1">
|
||||
@@ -48,26 +52,38 @@
|
||||
|
||||
|
||||
<div id="lobby-create" style="display:none">
|
||||
<h3>Create a Lobby</h3>
|
||||
<input type="text" id="lobby-input-name" placeholder="name">
|
||||
<h3><script>document.write(localeString('lobby-create'))</script></h3>
|
||||
<script>
|
||||
document.write(`<input type="text" id="lobby-input-name" placeholder="${localeString('name')}">`);
|
||||
</script>
|
||||
<p>
|
||||
<input type="checkbox" id="lobby-input-private"> private lobby
|
||||
<input type="checkbox" id="lobby-input-private"> <script>document.write(localeString('lobby-private'))</script>
|
||||
<p>
|
||||
<input type="checkbox" id="lobby-input-spectators"> allow spectators
|
||||
<input type="checkbox" id="lobby-input-spectators"> <script>document.write(localeString('lobby-allow-spectators'))</script>
|
||||
<p>
|
||||
<input type="button" value="create" onclick="createLobby()">
|
||||
<input type="button" value="back" onclick="showBack()">
|
||||
<script>
|
||||
document.write(`
|
||||
<input type="button" value="${localeString('button-create')}" onclick="createLobby()">
|
||||
<input type="button" value="${localeString('button-back')}" onclick="showBack()">
|
||||
`);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="lobby-join" style="display:none">
|
||||
<h3>Join a Lobby</h3>
|
||||
<input type="text" id="lobby-input-join-id" placeholder="lobby code">
|
||||
<h3><script>document.write(localeString('lobby-join'))</script></h3>
|
||||
<script>
|
||||
document.write(`<input type="text" id="lobby-input-join-id" placeholder="${localeString('lobby-code')}">`);
|
||||
</script>
|
||||
<p>
|
||||
<input type="checkbox" id="lobby-input-join-spectator"> join as spectator
|
||||
<input type="checkbox" id="lobby-input-join-spectator"> <script>document.write(localeString('lobby-join-spectator'))</script>
|
||||
<p>
|
||||
<input type="button" value="join" onclick="joinLobby()">
|
||||
<input type="button" value="back" onclick="showBack()">
|
||||
<script>
|
||||
document.write(`
|
||||
<input type="button" value="${localeString('button-join')}" onclick="joinLobby()">
|
||||
<input type="button" value="${localeString('button-back')}" onclick="showBack()">
|
||||
`);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="lobby-active" style="display:none">
|
||||
@@ -76,8 +92,12 @@
|
||||
|
||||
|
||||
<div id="console">
|
||||
<textarea id="log-console" rows="10" cols=auto placeholder="log console" disabled></textarea>
|
||||
<input id="log-console-message" type="text" placeholder="message"> <input id="log-console-button" type="button" value="send" onclick="sendMessage()">
|
||||
<script>
|
||||
document.write(`
|
||||
<textarea id="log-console" rows="10" cols=auto placeholder="${localeString('log-console')}" disabled></textarea>
|
||||
<input id="log-console-message" type="text" placeholder="${localeString('message')}"> <input id="log-console-button" type="button" value="${localeString('button-send')}" onclick="sendMessage()">
|
||||
`);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<script src="index.js"></script>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
function pageLog(message)
|
||||
{
|
||||
document.querySelector('#log-console').value += message + "\n"
|
||||
document.querySelector('#log-console').scrollTop = document.querySelector('#log-console').scrollHeight
|
||||
document.querySelector('#log-console').scrollTop = document.querySelector('#log-console').scrollHeight;
|
||||
}
|
||||
|
||||
function onConnect()
|
||||
@@ -16,5 +16,5 @@ function onDisconnect()
|
||||
{
|
||||
destructLobbies();
|
||||
|
||||
document.location.href = document.location.href + '../';
|
||||
document.location.href += '../';
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
const ConnectionState = document.querySelector('#connection-state');
|
||||
|
||||
|
||||
ConnectionState.innerHTML = 'Waiting for connection'
|
||||
ConnectionState.innerHTML = localeString('connection-waiting');
|
||||
|
||||
const socket = io(window.location.host);
|
||||
|
||||
// do not to be locale-ised because they do not communicate information
|
||||
// to the user and are technical in nature
|
||||
socket.on('connect', (...args) => {
|
||||
console.log('Socket Connected');
|
||||
ConnectionState.innerHTML = 'Waiting for identify'
|
||||
@@ -24,7 +25,7 @@ socket.on('identify', (...args) => {
|
||||
{
|
||||
socket.disconnect();
|
||||
ConnectionState.innerHTML = 'Identify cannot proceed, no user';
|
||||
document.location.href = document.location.href + '../';
|
||||
document.location.href += '../';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ socket.on('identify', (...args) => {
|
||||
{
|
||||
socket.disconnect();
|
||||
ConnectionState.innerHTML = 'Identify cannot proceed, corrupted user';
|
||||
document.location.href = document.location.href + '../';
|
||||
document.location.href += '../';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ socket.on('identify', (...args) => {
|
||||
{
|
||||
socket.disconnect();
|
||||
ConnectionState.innerHTML = 'Identify cannot proceed, corrupted user';
|
||||
document.location.href = document.location.href + '../';
|
||||
document.location.href += '../';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ socket.on('identify', (...args) => {
|
||||
|
||||
socket.on('identify-success', (...args) => {
|
||||
console.log(args[0]);
|
||||
ConnectionState.innerHTML = `${args[0].user.state} as ${args[0].user.username}`;
|
||||
ConnectionState.innerHTML = localeString('status-connected-as') + args[0].user.username;
|
||||
onConnect();
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ function drawLobby(lobby)
|
||||
lobbyDiv.id = lobby.id;
|
||||
|
||||
// TODO: Make drawlobby function
|
||||
lobbyDiv.innerHTML += `<h2>Lobby ${lobby.name}</h2><p><h3>Join Code: <b>${lobby.uid}</b></h3><p>Players:`;
|
||||
lobbyDiv.innerHTML += `<h2>${localeString('lobby')} ${lobby.name}</h2><p><h3>${localeString('lobby-join-code')}: <b>${lobby.uid}</b></h3><p>${localeString('players')}:`;
|
||||
|
||||
for (const player of lobby.players)
|
||||
lobbyDiv.innerHTML += `<b>${player.name}</b>, `
|
||||
@@ -59,16 +59,16 @@ function drawLobby(lobby)
|
||||
|
||||
if (lobby.allowspectators)
|
||||
{
|
||||
lobbyDiv.innerHTML += '<p>Spectators:';
|
||||
lobbyDiv.innerHTML += `<p>${localeString('spectators')}:`;
|
||||
for (const player of lobby.spectators)
|
||||
lobbyDiv.innerHTML += `<b>${player.name}</b>, `
|
||||
lobbyDiv.innerHTML = lobbyDiv.innerHTML.slice(0, -2);
|
||||
}
|
||||
|
||||
lobbyDiv.innerHTML += `<p>Visibility: ${lobby.visibility}<p>State: ${lobby.state}`
|
||||
lobbyDiv.innerHTML += `<p>${localeString('visibility')}: ${lobby.visibility}<p>${localeString('status')}: ${lobby.state}`
|
||||
|
||||
lobbyDiv.innerHTML += '<input type="button" value="Start Game" onclick="" disabled>'
|
||||
lobbyDiv.innerHTML += '<input type="button" value="Leave Lobby" onclick="leaveLobby()">'
|
||||
lobbyDiv.innerHTML += `<input type="button" value="${localeString('button-start-game')}" onclick="" disabled>`
|
||||
lobbyDiv.innerHTML += `<input type="button" value="${localeString('button-leave-lobby')}" onclick="leaveLobby()">`
|
||||
|
||||
ActiveLobbyBlock.appendChild(lobbyDiv);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function createLobby()
|
||||
{
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.id = 'lobby-error';
|
||||
errorDiv.innerHTML = 'ERROR: LobbyName is required';
|
||||
errorDiv.innerHTML = localeString('error-bold') + localeString('error-lobby-name-required');
|
||||
errorDiv.classList.add('red');
|
||||
CreateLobbyBlock.appendChild(errorDiv);
|
||||
return;
|
||||
@@ -122,9 +122,9 @@ socket.on('lobby-create-success', obj => {
|
||||
|
||||
const successDiv = document.createElement('div');
|
||||
successDiv.id = 'lobby-success';
|
||||
successDiv.innerHTML = 'SUCCESS: Lobby created, Joining...';
|
||||
successDiv.innerHTML = localeString('lobby-created-joining');
|
||||
CreateLobbyBlock.appendChild(successDiv);
|
||||
pageLog(`created lobby ${obj.lobby.uid} (${(obj.lobby.name)})`);
|
||||
pageLog(`${localeString('lobby-created')} ${obj.lobby.uid} (${(obj.lobby.name)})`);
|
||||
});
|
||||
|
||||
socket.on('lobby-create-error', obj => {
|
||||
@@ -133,10 +133,10 @@ socket.on('lobby-create-error', obj => {
|
||||
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.id = 'lobby-error';
|
||||
errorDiv.innerHTML = 'ERROR: An error occured while creating the lobby' + JSON.stringify(args);
|
||||
errorDiv.innerHTML = localeString('error-bold') + localeString('error-creating-lobby') + JSON.stringify(args);
|
||||
errorDiv.classList.add('red');
|
||||
CreateLobbyBlock.appendChild(errorDiv);
|
||||
pageLog('ERROR: An error occured while creating the lobby ' + JSON.stringify(args));
|
||||
pageLog(localeString('error-bold') + localeString('error-creating-lobby') + JSON.stringify(args));
|
||||
});
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ function joinLobby()
|
||||
{
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.id = 'lobby-error';
|
||||
errorDiv.innerHTML = 'ERROR: A Lobby ID is required';
|
||||
errorDiv.innerHTML = localeString('error-bold') + localeString('error-lobby-id-required');
|
||||
errorDiv.classList.add('red');
|
||||
JoinLobbyBlock.appendChild(errorDiv);
|
||||
return;
|
||||
@@ -178,14 +178,14 @@ function joinLobby()
|
||||
if (document.querySelector('#lobby-error'))
|
||||
document.querySelector('#lobby-error').remove();
|
||||
|
||||
pageLog(`joining lobby ${lobbyuid}`);
|
||||
pageLog(`${localeString('lobby-joining')} ${lobbyuid}`);
|
||||
|
||||
}
|
||||
|
||||
socket.on('lobby-join-success', lobby => {
|
||||
showActive();
|
||||
drawLobby(lobby);
|
||||
pageLog(`joined lobby ${lobby.uid} (${(lobby.name)})`);
|
||||
pageLog(`${localeString('lobby-joined')} ${lobby.uid} (${(lobby.name)})`);
|
||||
});
|
||||
|
||||
socket.on('lobby-join-error', obj => {
|
||||
@@ -194,10 +194,10 @@ socket.on('lobby-join-error', obj => {
|
||||
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.id = 'lobby-error';
|
||||
errorDiv.innerHTML = 'ERROR: An error occured while joining the lobby ' + JSON.stringify(obj);
|
||||
errorDiv.innerHTML = localeString('error-bold') + localeString('error-lobby-joining') + JSON.stringify(obj);
|
||||
errorDiv.classList.add('red');
|
||||
JoinLobbyBlock.appendChild(errorDiv);
|
||||
pageLog('ERROR: An error occured while joining the lobby ' + JSON.stringify(obj));
|
||||
pageLog(localeString('error-bold') + localeString('error-lobby-joining') + JSON.stringify(obj));
|
||||
});
|
||||
|
||||
socket.on('lobby-update', obj => {
|
||||
@@ -209,14 +209,14 @@ socket.on('lobby-update', obj => {
|
||||
drawLobby(obj.lobby);
|
||||
|
||||
if (obj.state === 'lobby-join')
|
||||
pageLog(`${obj.updateuser.username} joined`);
|
||||
pageLog(`${obj.updateuser.username} ${localeString('joined')}`);
|
||||
|
||||
if (obj.state ==='lobby-leave')
|
||||
pageLog(`${obj.updateuser.username} left`);
|
||||
pageLog(`${obj.updateuser.username} ${localeString('left')}`);
|
||||
|
||||
if (obj.state === 'lobby-deregister')
|
||||
{
|
||||
pageLog(`${obj.updateuser.username} deleted lobby`);
|
||||
pageLog(`${obj.updateuser.username} ${localeString('lobby-deleted')}`);
|
||||
leaveLobby();
|
||||
}
|
||||
});
|
||||
@@ -225,7 +225,7 @@ function leaveLobby()
|
||||
{
|
||||
// TODO: error check
|
||||
socket.emit('lobby-leave');
|
||||
pageLog('left lobby');
|
||||
pageLog(localeString('left-lobby'));
|
||||
showBack();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,17 @@
|
||||
<form id="input-username">
|
||||
<label for="input-text-username"><script>document.write(localeString('username'))</script>: </label>
|
||||
<input id="input-text-username" type="text">
|
||||
<button type="submit">Submit</button>
|
||||
<button type="submit"><script>document.write(localeString('button-submit'))</script></button>
|
||||
</form>
|
||||
|
||||
<div id="connection-state"></div>
|
||||
|
||||
<p><p>
|
||||
|
||||
<input type="button" value="play singleplayer" onclick="playSingleplayer()">
|
||||
<!--annoying hack kinda required tho-->
|
||||
<script>
|
||||
document.write(`<input type="button" value="${localeString('button-singleplayer')}" onclick="playSingleplayer()">`);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<script src="index.js"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@ UsernameForm.addEventListener('submit', onUsernameSubmit);
|
||||
|
||||
function playSingleplayer()
|
||||
{
|
||||
document.location.href += '/scrabble';
|
||||
window.location.pathname = "/scrabble";
|
||||
}
|
||||
|
||||
// User submits their desired username
|
||||
@@ -38,7 +38,7 @@ async function onUsernameSubmit(e)
|
||||
if (body.errors)
|
||||
{
|
||||
ConnectionState.classList.add('red');
|
||||
ConnectionState.innerHTML = `ERROR: ${body.errors[body.errors.length - 1].desc}`;
|
||||
ConnectionState.innerHTML = `${localeString('error-bold')}: ${localeString(body.errors[body.errors.length - 1].desc)}`;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ async function onUsernameSubmit(e)
|
||||
{
|
||||
sessionStorage.setItem('user', JSON.stringify(body.login.user));
|
||||
console.log(sessionStorage.user)
|
||||
document.location.href += 'game';
|
||||
window.location.pathname = "/game";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,15 @@ window.onload = e => {
|
||||
const boardLocation = document.querySelector(`#row-${y}`).querySelector(`#col-${x}`);
|
||||
|
||||
boardLocation.classList.add(BoardLookup[BoardLocations[location]]);
|
||||
boardLocation.innerHTML = BoardLocations[location];
|
||||
let localeThing = BoardLocations[location];
|
||||
|
||||
// hacky but it works
|
||||
if (localStorage.getItem('locale') === "es" || localStorage.getItem('locale') === "pt")
|
||||
{
|
||||
localeThing = localeThing.replace('W', 'P');
|
||||
}
|
||||
|
||||
boardLocation.innerHTML = localeThing;
|
||||
}
|
||||
|
||||
// flip it
|
||||
@@ -73,6 +81,13 @@ window.onload = e => {
|
||||
const boardLocation = document.querySelector(`#row-${y}`).querySelector(`#col-${x}`);
|
||||
|
||||
boardLocation.classList.add(BoardLookup[BoardLocations[location]]);
|
||||
boardLocation.innerHTML = BoardLocations[location];
|
||||
let localeThing = BoardLocations[location];
|
||||
|
||||
if (localStorage.getItem('locale') === "es" || localStorage.getItem('locale') === "pt")
|
||||
{
|
||||
localeThing = localeThing.replace('W', 'P');
|
||||
}
|
||||
|
||||
boardLocation.innerHTML = localeThing;
|
||||
}
|
||||
};
|
||||
|
||||
288
data/locale.json
Normal file
288
data/locale.json
Normal file
@@ -0,0 +1,288 @@
|
||||
{
|
||||
"scrabble-name": {
|
||||
"en": "Scrabble",
|
||||
"es": "Scrabble",
|
||||
"pt": "Scrabble"
|
||||
},
|
||||
"game-lobby": {
|
||||
"en": "create or join a game",
|
||||
"es": "Crea o conecta a un juego",
|
||||
"pt": "Crie ou entre em um jogo"
|
||||
},
|
||||
"name": {
|
||||
"en": "name",
|
||||
"es": "nombre",
|
||||
"pt": "nome"
|
||||
},
|
||||
"username": {
|
||||
"en": "Username",
|
||||
"es": "Nombre de usuario",
|
||||
"pt": "Nome de usuàrio"
|
||||
},
|
||||
"players": {
|
||||
"en": "Players",
|
||||
"es": "Jugadores",
|
||||
"pt": "Jogadores"
|
||||
},
|
||||
"button-singleplayer": {
|
||||
"en": "Play singleplayer",
|
||||
"es": "Jugar a un(a) jugador(a)",
|
||||
"pt": "Jogar singleplayer"
|
||||
},
|
||||
"button-submit": {
|
||||
"en": "Submit",
|
||||
"es": "Enviar",
|
||||
"pt": "Enviar"
|
||||
},
|
||||
"button-create": {
|
||||
"en": "create",
|
||||
"es": "crear",
|
||||
"pt": "criar"
|
||||
},
|
||||
"button-join": {
|
||||
"en": "join",
|
||||
"es": "participar",
|
||||
"pt": "entrar"
|
||||
},
|
||||
"button-back": {
|
||||
"en": "back",
|
||||
"es": "regresar",
|
||||
"pt": "voltar"
|
||||
},
|
||||
|
||||
"status-connected": {
|
||||
"en": "Connected",
|
||||
"es": "Conectado(a)",
|
||||
"pt": "Conectado(a)"
|
||||
},
|
||||
"status-connected-as": {
|
||||
"en": "Connected as ",
|
||||
"es": "Conectado/a como ",
|
||||
"pt": "Conectado/a como "
|
||||
},
|
||||
"status-disconnected": {
|
||||
"en": "Disconnected",
|
||||
"es": "Desconectado/a",
|
||||
"pt": "Desconectado/a"
|
||||
},
|
||||
"connection-waiting": {
|
||||
"en": "Waiting for connection",
|
||||
"es": "Esperando la conexión",
|
||||
"pt": "Aguardando conexão"
|
||||
},
|
||||
|
||||
"message": {
|
||||
"en": "message",
|
||||
"es": "mensaje",
|
||||
"pt": "mensagem"
|
||||
},
|
||||
"log-console": {
|
||||
"en": "log console",
|
||||
"es": "consola de log",
|
||||
"pt": "console de log"
|
||||
},
|
||||
"button-send": {
|
||||
"en": "send",
|
||||
"es": "enviar",
|
||||
"pt": "enviar"
|
||||
},
|
||||
|
||||
"lobby": {
|
||||
"en": "Lobby",
|
||||
"es": "Lobby",
|
||||
"pt": "Lobby"
|
||||
},
|
||||
"lobby-create": {
|
||||
"en": "Create Lobby",
|
||||
"es": "Crear Lobby",
|
||||
"pt": "Criar Lobby"
|
||||
},
|
||||
"lobby-join": {
|
||||
"en": "Join Lobby",
|
||||
"es": "Conectarse al Lobby",
|
||||
"pt": "Conectar ao Lobby"
|
||||
},
|
||||
"lobby-join-code": {
|
||||
"en": "Join Code",
|
||||
"es": "Código para Conectar",
|
||||
"pt": "Código para Conectar"
|
||||
},
|
||||
"lobby-code": {
|
||||
"en": "lobby code",
|
||||
"es": "código de lobby",
|
||||
"pt": "código do lobby"
|
||||
},
|
||||
"lobby-private": {
|
||||
"en": "private lobby",
|
||||
"es": "lobby privado",
|
||||
"pt": "lobby privado"
|
||||
},
|
||||
"lobby-allow-spectators": {
|
||||
"en": "allow spectators",
|
||||
"es": "permitir espectadores",
|
||||
"pt": "permitir espectadores"
|
||||
},
|
||||
"lobby-join-spectator": {
|
||||
"en": "join as spectator",
|
||||
"es": "conectar como espectador(a)",
|
||||
"pt": "junte-se como espectador"
|
||||
},
|
||||
"lobby-created-joining": {
|
||||
"en": "Lobby created, Joining...",
|
||||
"es": "Lobby creado, Conectando...",
|
||||
"pt": "Lobby criaso, Juntando-se..."
|
||||
},
|
||||
"lobby-created": {
|
||||
"en": "created lobby",
|
||||
"es": "lobby creado",
|
||||
"pt": "Lobby criado"
|
||||
},
|
||||
"lobby-joining": {
|
||||
"en": "joining lobby",
|
||||
"es": "entrando al lobby",
|
||||
"pt": "entrando no lobby"
|
||||
},
|
||||
"lobby-joined": {
|
||||
"en": "joined lobby",
|
||||
"es": "entró en el lobby",
|
||||
"pt": "entrou no lobby"
|
||||
},
|
||||
"lobby-deleted": {
|
||||
"en": "deleted lobby",
|
||||
"es": "lobby eliminado",
|
||||
"pt": "lobby apagado"
|
||||
},
|
||||
"joined": {
|
||||
"en": "joined",
|
||||
"es": "conectado(a)",
|
||||
"pt": "juntou"
|
||||
},
|
||||
"left": {
|
||||
"en": "left",
|
||||
"es": "salió",
|
||||
"pt": "saiu"
|
||||
},
|
||||
"left-lobby": {
|
||||
"en": "left lobby",
|
||||
"es": "salió del lobby",
|
||||
"pt": "saiu do lobby"
|
||||
},
|
||||
|
||||
"spectators": {
|
||||
"en": "Spectators",
|
||||
"es": "Espectadores",
|
||||
"pt": "Espectadores"
|
||||
},
|
||||
"visibility": {
|
||||
"en": "Visibility",
|
||||
"es": "Visibilidad",
|
||||
"pt": "Visibilidade"
|
||||
},
|
||||
"status": {
|
||||
"en": "Status",
|
||||
"es": "Status",
|
||||
"pt": "Status"
|
||||
},
|
||||
"button-start-game": {
|
||||
"en": "Start Game",
|
||||
"es": "Empezar Juego",
|
||||
"pt": "Começar Jogo"
|
||||
},
|
||||
"button-leave-lobby": {
|
||||
"en": "Leave Lobby",
|
||||
"es": "Salir del Lobby",
|
||||
"pt": "Sair do Lobby"
|
||||
},
|
||||
|
||||
|
||||
"error-bold": {
|
||||
"en": "ERROR",
|
||||
"es": "ERRO",
|
||||
"pt": "ERROR"
|
||||
},
|
||||
"error-no-username": {
|
||||
"en": "Username not present",
|
||||
"es": "Nombre de usuario no esta presente",
|
||||
"pt": "Nome de usuário não esta presente"
|
||||
},
|
||||
"error-invalid-username": {
|
||||
"en": "Invalid username",
|
||||
"es": "Nombre de usuario no es válido",
|
||||
"pt": "Nome de usuário Inválido"
|
||||
},
|
||||
"error-taken-username": {
|
||||
"en": "Username taken",
|
||||
"es": "Nombre de usuario no esta disponible",
|
||||
"pt": "Nome de usuário já está em uso"
|
||||
},
|
||||
"error-too-many-clients": {
|
||||
"en": "Too many connections",
|
||||
"es": "Demasiadas conexiones",
|
||||
"pt": "Demasiadas conexões"
|
||||
},
|
||||
"error-bad-intent": {
|
||||
"en": "Client has no intent",
|
||||
"es": "Cliente no tiene intención",
|
||||
"pt": "Cliente não tem intenção"
|
||||
},
|
||||
"error-unknown-uid": {
|
||||
"en": "Unknown user ID",
|
||||
"es": "ID de usuario desconocido",
|
||||
"pt": "ID de usuário desconhecido"
|
||||
},
|
||||
"error-taken-user-connection": {
|
||||
"en": "User already connected",
|
||||
"es": "Usuario ya está conectado/a",
|
||||
"pt": "Usuário já está conectado/a"
|
||||
},
|
||||
"error-illegal-user": {
|
||||
"en": "Illegal user",
|
||||
"es": "Usuario ilegal",
|
||||
"pt": "Usuário ilegal"
|
||||
},
|
||||
"error-malformed-lobby": {
|
||||
"en": "Lobby malformed",
|
||||
"es": "Lobby malformado",
|
||||
"pt": "Lobby malformado"
|
||||
},
|
||||
"error-taken-lobby-ownership": {
|
||||
"en": "User already owns lobby",
|
||||
"es": "Usuario ya tiene lobby",
|
||||
"pt": "Usuário já tem um lobby"
|
||||
},
|
||||
"error-illegal-lobby": {
|
||||
"en": "Illegal lobby",
|
||||
"es": "Lobby ilegal",
|
||||
"pt": "Lobby ilegal"
|
||||
},
|
||||
"error-cannot-join-lobby": {
|
||||
"en": "Cannot join lobby",
|
||||
"es": "No se puede unir al lobby",
|
||||
"pt": "Não é possível entrar no lobby"
|
||||
},
|
||||
"error-lobby-not-exist": {
|
||||
"en": "Lobby does not exist",
|
||||
"es": "Lobby no existe",
|
||||
"pt": "Lobby não existe"
|
||||
},
|
||||
"error-lobby-name-required": {
|
||||
"en": "A name is requred",
|
||||
"es": "Se requiere un nombre",
|
||||
"pt": "Um nome é obrigatório"
|
||||
},
|
||||
"error-creating-lobby": {
|
||||
"en": "An error occurred while creating the lobby ",
|
||||
"es": "Ocurrió un error al crear el lobby ",
|
||||
"pt": "Ocorreu um erro ao criar o lobby "
|
||||
},
|
||||
"error-lobby-id-required": {
|
||||
"en": "A lobby ID is required",
|
||||
"es": "Se requiere un lobby ID",
|
||||
"pt": "É necessário um lobby ID"
|
||||
},
|
||||
"error-lobby-joining": {
|
||||
"en": "An error occurred while joining the lobby ",
|
||||
"es": "Ocurrió un error al conectarse al lobby ",
|
||||
"pt": "Ocorreu um erro ao entrar no lobby "
|
||||
}
|
||||
}
|
||||
0
scripts/deploy.js
Normal file
0
scripts/deploy.js
Normal file
0
scripts/langParser.js
Normal file
0
scripts/langParser.js
Normal file
0
scripts/localeToLang.js
Normal file
0
scripts/localeToLang.js
Normal file
@@ -1,110 +0,0 @@
|
||||
{
|
||||
"scrabble-name": {
|
||||
"en": "Scrabble",
|
||||
"es": "Scrabble",
|
||||
"pt": "Scrabble"
|
||||
},
|
||||
"username": {
|
||||
"en": "Username",
|
||||
"es": "Nombre de usuario",
|
||||
"pt": "Nome de usuàrio"
|
||||
},
|
||||
"button-singleplayer": {
|
||||
"en": "Play singleplayer",
|
||||
"es": "Jugar a un(a) jugador(a)",
|
||||
"pt": "Jogar singleplayer"
|
||||
},
|
||||
"button-submit": {
|
||||
"en": "Submit",
|
||||
"es": "Enviar",
|
||||
"pt": "Enviar"
|
||||
},
|
||||
"status-connected": {
|
||||
"en": "Connected",
|
||||
"es": "Conectado(a)",
|
||||
"pt": "Conectado(a)"
|
||||
},
|
||||
|
||||
|
||||
"error-bold": {
|
||||
"en": "ERROR",
|
||||
"es": "ERRO",
|
||||
"pt": "ERROR"
|
||||
},
|
||||
"error-no-username": {
|
||||
"en": "Username not present",
|
||||
"es": "Nombre de usuario no esta presente",
|
||||
"pt": "Nome de usuário não esta presente"
|
||||
},
|
||||
"error-invalid-username": {
|
||||
"en": "Invalid username",
|
||||
"es": "Nombre de usuario no es válido",
|
||||
"pt": "Nome de usuário Inválido"
|
||||
},
|
||||
"error-taken-username": {
|
||||
"en": "Username taken",
|
||||
"es": "Nombre de usuario no esta disponible",
|
||||
"pt": "Nome de usuário já está em uso"
|
||||
},
|
||||
"error-too-many-clients": {
|
||||
"en": "Too many connections",
|
||||
"es": "Demasiadas conexiones",
|
||||
"pt": "Demasiadas conexões"
|
||||
},
|
||||
"error-bad-intent": {
|
||||
"en": "Client has no intent",
|
||||
"es": "Cliente no tiene intención",
|
||||
"pt": "Cliente não tem intenção"
|
||||
},
|
||||
"error-unknown-uid": {
|
||||
"en": "Unknown user ID",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-taken-user-connection": {
|
||||
"en": "User already connected",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-illegal-user": {
|
||||
"en": "Illegal user",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-malformed-lobby": {
|
||||
"en": "Lobby malformed",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-taken-lobby-ownership": {
|
||||
"en": "User already owns lobby",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-illegal-lobby": {
|
||||
"en": "Illegal lobby",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-cannot-join-lobby": {
|
||||
"en": "Cannot join lobby",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-lobby-not-exist": {
|
||||
"en": "Lobby does not exist",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
"error-lobby-join": {
|
||||
"en": "Cannot join lobby",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
},
|
||||
|
||||
|
||||
|
||||
"en": "",
|
||||
"es": "",
|
||||
"pt": ""
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
const Logger = require('./logger.js');
|
||||
|
||||
const FS = require('fs');
|
||||
|
||||
let locales = {};
|
||||
|
||||
function init()
|
||||
async function init()
|
||||
{
|
||||
locales = JSON.parse(FS.readFileSync('./locale.json'));
|
||||
locales = JSON.parse(FS.readFileSync('../data/locale.json'));
|
||||
Logger.info('LOCALES LOADED');
|
||||
}
|
||||
|
||||
function GetLocaleListJSON()
|
||||
|
||||
@@ -101,6 +101,8 @@ function ClientIdentify(socket, args)
|
||||
}
|
||||
}
|
||||
|
||||
// if i use a database in the future i need to consider that the lobby
|
||||
// name is not yet sanatised
|
||||
function LobbyCreate(socket, args)
|
||||
{
|
||||
const err = new Error;
|
||||
@@ -201,7 +203,7 @@ function LobbyJoin(socket, args)
|
||||
// Make sure user isn't already in a lobby
|
||||
if (!Game.Lobbies.CheckUserAvailability(useruid))
|
||||
{
|
||||
err.addError(400, 'Bad Request', 'Uerror-taken-lobby-ownership');
|
||||
err.addError(400, 'Bad Request', 'error-taken-lobby-ownership');
|
||||
socket.emit('lobby-join-error', err.toError);
|
||||
return;
|
||||
}
|
||||
@@ -223,7 +225,7 @@ function LobbyJoin(socket, args)
|
||||
|
||||
if (!status)
|
||||
{
|
||||
err.addError(403, 'Forbidden', 'error-lobby-join');
|
||||
err.addError(403, 'Forbidden', 'error-cannot-join-lobby');
|
||||
socket.emit('lobby-join-error', err.toError);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user