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
@i18ns = loadJSON './data/i18n.json'
@i18nR = {}
for lang, data of @i18ns
@i18nR[lang]={}
for key, text of data
@i18nR[lang][key]={
regex: new RegExp("\\$\\{"+key+"\\}",'g'),
text: text
}
@reloadI18nR = () ->
for lang, data of @i18ns
@i18nR[lang]={}
for key, text of data
@i18nR[lang][key]={
regex: new RegExp("\\$\\{"+key+"\\}",'g'),
text: text
}
reloadI18nR()
YGOProMessagesHelper = require("./YGOProMessages.js").YGOProMessagesHelper # 为 SRVPro2 准备的库,这里拿这个库只用来测试,SRVPro1 对异步支持不是特别完善,因此不会有很多异步优化
@helper = new YGOProMessagesHelper(9000)
......
// Generated by CoffeeScript 2.5.1
(function() {
var Struct, YGOProMessagesHelper, _, data, key, lang, loadJSON, ref, text, translateHandler;
var Struct, YGOProMessagesHelper, _, loadJSON, translateHandler;
_ = require('underscore');
......@@ -16,18 +16,30 @@
this.i18nR = {};
ref = this.i18ns;
for (lang in ref) {
data = ref[lang];
this.i18nR[lang] = {};
for (key in data) {
text = data[key];
this.i18nR[lang][key] = {
regex: new RegExp("\\$\\{" + key + "\\}", 'g'),
text: text
};
this.reloadI18nR = function() {
var data, key, lang, ref, results, text;
ref = this.i18ns;
results = [];
for (lang in ref) {
data = ref[lang];
this.i18nR[lang] = {};
results.push((function() {
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 对异步支持不是特别完善,因此不会有很多异步优化
......@@ -84,20 +96,20 @@
//util
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) {
console.log("err stoc_send_chat");
return;
}
ref1 = _.lines(msg);
for (i = 0, len = ref1.length; i < len; i++) {
line = ref1[i];
ref = _.lines(msg);
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
if (player >= 10) {
line = "[Server]: " + line;
}
ref2 = this.i18nR[client.lang];
for (o in ref2) {
r = ref2[o];
ref1 = this.i18nR[client.lang];
for (o in ref1) {
r = ref1[o];
line = line.replace(r.regex, r.text);
}
this.stoc_send(client, 'CHAT', {
......@@ -108,21 +120,21 @@
};
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) {
console.log("err stoc_send_chat_to_room");
return;
}
ref1 = room.players;
for (i = 0, len = ref1.length; i < len; i++) {
client = ref1[i];
ref = room.players;
for (i = 0, len = ref.length; i < len; i++) {
client = ref[i];
if (client) {
this.stoc_send_chat(client, msg, player);
}
}
ref2 = room.watchers;
for (j = 0, len1 = ref2.length; j < len1; j++) {
client = ref2[j];
ref1 = room.watchers;
for (j = 0, len1 = ref1.length; j < len1; j++) {
client = ref1[j];
if (client) {
this.stoc_send_chat(client, msg, player);
}
......@@ -130,14 +142,14 @@
};
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) {
console.log("err stoc_send_hint_card_to_room");
return;
}
ref1 = room.players;
for (i = 0, len = ref1.length; i < len; i++) {
client = ref1[i];
ref = room.players;
for (i = 0, len = ref.length; i < len; i++) {
client = ref[i];
if (client) {
this.stoc_send(client, 'GAME_MSG', {
curmsg: 2,
......@@ -147,9 +159,9 @@
});
}
}
ref2 = room.watchers;
for (j = 0, len1 = ref2.length; j < len1; j++) {
client = ref2[j];
ref1 = room.watchers;
for (j = 0, len1 = ref1.length; j < len1; j++) {
client = ref1[j];
if (client) {
this.stoc_send(client, 'GAME_MSG', {
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