Commit 1109ce18 authored by nanahira's avatar nanahira

fix i18ns

parent 9ad14874
Pipeline #4781 failed with stages
in 23 minutes and 21 seconds
...@@ -8,13 +8,16 @@ loadJSON = require('load-json-file').sync ...@@ -8,13 +8,16 @@ loadJSON = require('load-json-file').sync
@i18ns = loadJSON './data/i18n.json' @i18ns = loadJSON './data/i18n.json'
@i18nR = {} @i18nR = {}
for lang, data of @i18ns @reloadI18nR = () ->
@i18nR[lang]={} for lang, data of @i18ns
for key, text of data @i18nR[lang]={}
@i18nR[lang][key]={ for key, text of data
regex: new RegExp("\\$\\{"+key+"\\}",'g'), @i18nR[lang][key]={
text: text regex: new RegExp("\\$\\{"+key+"\\}",'g'),
} text: text
}
reloadI18nR()
YGOProMessagesHelper = require("./YGOProMessages.js").YGOProMessagesHelper # 为 SRVPro2 准备的库,这里拿这个库只用来测试,SRVPro1 对异步支持不是特别完善,因此不会有很多异步优化 YGOProMessagesHelper = require("./YGOProMessages.js").YGOProMessagesHelper # 为 SRVPro2 准备的库,这里拿这个库只用来测试,SRVPro1 对异步支持不是特别完善,因此不会有很多异步优化
@helper = new YGOProMessagesHelper(9000) @helper = new YGOProMessagesHelper(9000)
......
// Generated by CoffeeScript 2.5.1 // Generated by CoffeeScript 2.5.1
(function() { (function() {
var Struct, YGOProMessagesHelper, _, data, key, lang, loadJSON, ref, text, translateHandler; var Struct, YGOProMessagesHelper, _, loadJSON, translateHandler;
_ = require('underscore'); _ = require('underscore');
...@@ -16,18 +16,30 @@ ...@@ -16,18 +16,30 @@
this.i18nR = {}; this.i18nR = {};
ref = this.i18ns; this.reloadI18nR = function() {
for (lang in ref) { var data, key, lang, ref, results, text;
data = ref[lang]; ref = this.i18ns;
this.i18nR[lang] = {}; results = [];
for (key in data) { for (lang in ref) {
text = data[key]; data = ref[lang];
this.i18nR[lang][key] = { this.i18nR[lang] = {};
regex: new RegExp("\\$\\{" + key + "\\}", 'g'), results.push((function() {
text: text var results1;
}; results1 = [];
for (key in data) {
text = data[key];
results1.push(this.i18nR[lang][key] = {
regex: new RegExp("\\$\\{" + key + "\\}", 'g'),
text: text
});
}
return results1;
}).call(this));
} }
} return results;
};
reloadI18nR();
YGOProMessagesHelper = require("./YGOProMessages.js").YGOProMessagesHelper; // 为 SRVPro2 准备的库,这里拿这个库只用来测试,SRVPro1 对异步支持不是特别完善,因此不会有很多异步优化 YGOProMessagesHelper = require("./YGOProMessages.js").YGOProMessagesHelper; // 为 SRVPro2 准备的库,这里拿这个库只用来测试,SRVPro1 对异步支持不是特别完善,因此不会有很多异步优化
...@@ -84,20 +96,20 @@ ...@@ -84,20 +96,20 @@
//util //util
this.stoc_send_chat = function(client, msg, player = 8) { this.stoc_send_chat = function(client, msg, player = 8) {
var i, len, line, o, r, ref1, ref2; var i, len, line, o, r, ref, ref1;
if (!client) { if (!client) {
console.log("err stoc_send_chat"); console.log("err stoc_send_chat");
return; return;
} }
ref1 = _.lines(msg); ref = _.lines(msg);
for (i = 0, len = ref1.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i++) {
line = ref1[i]; line = ref[i];
if (player >= 10) { if (player >= 10) {
line = "[Server]: " + line; line = "[Server]: " + line;
} }
ref2 = this.i18nR[client.lang]; ref1 = this.i18nR[client.lang];
for (o in ref2) { for (o in ref1) {
r = ref2[o]; r = ref1[o];
line = line.replace(r.regex, r.text); line = line.replace(r.regex, r.text);
} }
this.stoc_send(client, 'CHAT', { this.stoc_send(client, 'CHAT', {
...@@ -108,21 +120,21 @@ ...@@ -108,21 +120,21 @@
}; };
this.stoc_send_chat_to_room = function(room, msg, player = 8) { this.stoc_send_chat_to_room = function(room, msg, player = 8) {
var client, i, j, len, len1, ref1, ref2; var client, i, j, len, len1, ref, ref1;
if (!room) { if (!room) {
console.log("err stoc_send_chat_to_room"); console.log("err stoc_send_chat_to_room");
return; return;
} }
ref1 = room.players; ref = room.players;
for (i = 0, len = ref1.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i++) {
client = ref1[i]; client = ref[i];
if (client) { if (client) {
this.stoc_send_chat(client, msg, player); this.stoc_send_chat(client, msg, player);
} }
} }
ref2 = room.watchers; ref1 = room.watchers;
for (j = 0, len1 = ref2.length; j < len1; j++) { for (j = 0, len1 = ref1.length; j < len1; j++) {
client = ref2[j]; client = ref1[j];
if (client) { if (client) {
this.stoc_send_chat(client, msg, player); this.stoc_send_chat(client, msg, player);
} }
...@@ -130,14 +142,14 @@ ...@@ -130,14 +142,14 @@
}; };
this.stoc_send_hint_card_to_room = function(room, card) { this.stoc_send_hint_card_to_room = function(room, card) {
var client, i, j, len, len1, ref1, ref2; var client, i, j, len, len1, ref, ref1;
if (!room) { if (!room) {
console.log("err stoc_send_hint_card_to_room"); console.log("err stoc_send_hint_card_to_room");
return; return;
} }
ref1 = room.players; ref = room.players;
for (i = 0, len = ref1.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i++) {
client = ref1[i]; client = ref[i];
if (client) { if (client) {
this.stoc_send(client, 'GAME_MSG', { this.stoc_send(client, 'GAME_MSG', {
curmsg: 2, curmsg: 2,
...@@ -147,9 +159,9 @@ ...@@ -147,9 +159,9 @@
}); });
} }
} }
ref2 = room.watchers; ref1 = room.watchers;
for (j = 0, len1 = ref2.length; j < len1; j++) { for (j = 0, len1 = ref1.length; j < len1; j++) {
client = ref2[j]; client = ref1[j];
if (client) { if (client) {
this.stoc_send(client, 'GAME_MSG', { this.stoc_send(client, 'GAME_MSG', {
curmsg: 2, curmsg: 2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment