From 34f3ab900a9cac78acb7a10d1ed60555d98ff822 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 25 Jun 2015 13:28:41 +0100 Subject: handle the multilingual support Signed-off-by: Olivier Gayot --- webapp/cao-common.js | 7 +++++++ webapp/cao-config.js | 13 +++++++++++++ webapp/cao-mobile.html | 1 + 3 files changed, 21 insertions(+) create mode 100644 webapp/cao-config.js diff --git a/webapp/cao-common.js b/webapp/cao-common.js index 6d92de7..0ec516d 100644 --- a/webapp/cao-common.js +++ b/webapp/cao-common.js @@ -28,6 +28,8 @@ var CAO = function() { var self = this; var ws; + var lang; + var nbr_played_cards = 0; var played_cards = []; @@ -39,6 +41,10 @@ var CAO = function() { var map_handle_response_ok = {}; var map_handle_notif = {}; + this.set_lang = function(language) { + lang = language; + }; + this.is_judge = function() { return judge; }; @@ -287,6 +293,7 @@ var CAO = function() { var request = { 'op': 'join_game', 'game_name': game_name, + 'lang': lang, }; request_queue.push('join_game'); ws.send(JSON.stringify(request)); diff --git a/webapp/cao-config.js b/webapp/cao-config.js new file mode 100644 index 0000000..2082e3a --- /dev/null +++ b/webapp/cao-config.js @@ -0,0 +1,13 @@ +$(document).ready(function() { + var lang; + var hostname = document.location.hostname; + + /* XXX replace this with your desired behaviour */ + if (hostname.startsWith('fr.')) { + lang = 'fr'; + } else if (hostname.startsWith('en.')) { + lang = 'en'; + } + + cao.set_lang(lang); +}); diff --git a/webapp/cao-mobile.html b/webapp/cao-mobile.html index a9f8722..7aa619d 100644 --- a/webapp/cao-mobile.html +++ b/webapp/cao-mobile.html @@ -8,6 +8,7 @@ + -- cgit v1.2.3