Просмотр исходного кода

Merge pull request #31 from Markus-Rost/translations

add null for strings en.json doesn't use
MarkusRost 4 лет назад
Родитель
Сommit
ebb9033d6e
13 измененных файлов с 41 добавлено и 27 удалено
  1. 2 1
      .gitattributes
  2. 2 1
      cmds/test.js
  3. 0 1
      i18n/de.json
  4. 28 6
      i18n/en.json
  5. 0 2
      i18n/fr.json
  6. 0 2
      i18n/nl.json
  7. 0 1
      i18n/pl.json
  8. 0 2
      i18n/pt.json
  9. 0 2
      i18n/ru.json
  10. 0 2
      i18n/tr.json
  11. 0 1
      i18n/zh-hans.json
  12. 0 1
      i18n/zh-hant.json
  13. 9 5
      util/i18n.js

+ 2 - 1
.gitattributes

@@ -1 +1,2 @@
-*.json  filter=tabindent
+*.json  filter=tabindent
+package.json -filter

+ 2 - 1
cmds/test.js

@@ -14,7 +14,8 @@ function cmd_test(lang, msg, args, line, wiki) {
 		if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
 	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) {
 		if ( msg.isAdmin() && msg.defaultSettings ) help_setup(lang, msg);
-		var text = lang.get('test.text')[Math.floor(Math.random() * lang.get('test.random'))] || lang.get('test.default');
+		let textList = lang.get('test.text').filter( text => text );
+		var text = textList[Math.floor(Math.random() * ( textList.length * 5 ))] || lang.get('test.default');
 		console.log( '- Test: Fully functioning!' );
 		var now = Date.now();
 		msg.replyMsg( text ).then( message => {

+ 0 - 1
i18n/de.json

@@ -361,7 +361,6 @@
 		"bot": "Du kannst mich mit diesem Link auf einen anderen Server einladen:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "ich bin auf diesem Server derzeit pausiert.",
 		"text": [
 			"ich bin ja schon wach!",

+ 28 - 6
i18n/en.json

@@ -1,14 +1,31 @@
 {
 	"__translator": [
 		"MarkusRost",
-		"violine1101"
+		"violine1101",
+		null, null,
+		null, null,
+		null, null,
+		null, null
 	],
 	"fallback": [
+		null,
+		null,
+		null,
+		null,
+		null
 	],
 	"aliases": {
-		"random": ["random", "🎲"],
-		"discussion": ["discussions"],
-		"command": ["command", "cmd"]
+		"bug": ["bug", null, null, null, null],
+		"command": ["command", "cmd", null, null, null],
+		"diff": ["diff", null, null, null, null],
+		"discussion": ["discussions", "discussion", null, null, null],
+		"help": ["help", null, null, null, null],
+		"invite": ["invite", null, null, null, null],
+		"overview": ["overview", null, null, null, null],
+		"page": ["page", null, null, null, null],
+		"random": ["random", "🎲", null, null, null],
+		"search": ["search", null, null, null, null],
+		"verify": ["verify", null, null, null, null]
 	},
 	"dateformat": "en-US",
 	"prefix": "the prefix for this server is `$1`. You can change the prefix with `$1settings prefix`. For a list of all commands see `$1help`.",
@@ -356,13 +373,18 @@
 		"bot": "Use this link to invite me to another server:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "I'm currently paused on this server.",
 		"text": [
 			"I'm still alive!",
 			"and believe me, I am still alive.",
 			"I'm doing science and I'm still alive.",
-			"I feel fantastic and I'm still alive."
+			"I feel fantastic and I'm still alive.",
+			"stop poking me, I'm working fine.",
+			null, null, null, null, null,
+			null, null, null, null, null,
+			null, null, null, null, null,
+			null, null, null, null, null,
+			null, null, null, null, null
 		],
 		"default": "I'm fully functional!",
 		"time": "Response time",

+ 0 - 2
i18n/fr.json

@@ -77,7 +77,6 @@
 		"pages": "Nombre de pages total :",
 		"edits": "Modifications :",
 		"users": "Utilisateurs actifs :",
-		"crossover": "Merged into:",
 		"description": "Description :",
 		"image": "Image :",
 		"none": "*aucun*"
@@ -192,7 +191,6 @@
 		"bot": "Utilisez ce lien pour m'inviter sur un autre serveur :"
 	},
 	"test": {
-		"random": 50,
 		"pause": "je suis présentement en pause sur ce serveur.",
 		"text": [
 			"Je suis toujours en vie !",

+ 0 - 2
i18n/nl.json

@@ -78,7 +78,6 @@
 		"pages": "Totaal pagina's:",
 		"edits": "Bewerkingen:",
 		"users": "Actieve gebruikers:",
-		"crossover": "Merged into:",
 		"description": "Beschrijving:",
 		"image": "Afbeelding:",
 		"none": "*niemand*"
@@ -191,7 +190,6 @@
 		"bot": "Gebruik deze link om mij aan een andere server uit te nodigen:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "Ik ben momenteel gepauzeerd op deze server.",
 		"text": [
 			"Ik leef nog steeds!",

+ 0 - 1
i18n/pl.json

@@ -351,7 +351,6 @@
 		"bot": "Użyj tego linku aby zaprosić mnie na inny serwer:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "Moje działanie jest obecnie wstrzymane na tym serwerze.",
 		"text": [
 			"Wciąż tu jestem!",

+ 0 - 2
i18n/pt.json

@@ -157,7 +157,6 @@
 		"pages": "Total de páginas:",
 		"edits": "Edições:",
 		"users": "Usuário ativos:",
-		"crossover": "Merged into:",
 		"description": "Descrição:",
 		"image": "Imagem:",
 		"none": "*nenhum*"
@@ -270,7 +269,6 @@
 		"bot": "Use este link para me convidar para outro servidor:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "eu estou atualmente em pausa neste servidor.",
 		"text": [
 			"eu ainda estou vivo!",

+ 0 - 2
i18n/ru.json

@@ -150,7 +150,6 @@
 		"pages": "Всего страниц:",
 		"edits": "Отредактировано:",
 		"users": "Активные пользователи:",
-		"crossover": "Merged into:",
 		"description": "Описание:",
 		"image": "Изображение:",
 		"none": "*нет*"
@@ -262,7 +261,6 @@
 		"bot": "Используйте эту ссылку, чтобы пригласить меня на другой сервер:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "В настоящее время я приостановлен на этом сервере.",
 		"text": [
 			"Я все еще жив!",

+ 0 - 2
i18n/tr.json

@@ -78,7 +78,6 @@
 		"pages": "Toplam sayfalar:",
 		"edits": "Düzenlemeler:",
 		"users": "Aktif kullanıcılar:",
-		"crossover": "Merged into:",
 		"description": "Açıklama:",
 		"image": "Resim:",
 		"none": "*hiçbiri*"
@@ -191,7 +190,6 @@
 		"bot": "Beni başka bir sunucuya davet etmek için bu bağlantıyı kullan:"
 	},
 	"test": {
-		"random": 10,
 		"pause": "Şu anda bu sunucuda duraklatılmış durumdayım.",
 		"text": [
 			"Hala hayattayım!",

+ 0 - 1
i18n/zh-hans.json

@@ -355,7 +355,6 @@
 		"bot": "使用这个链接把我添加到其他服务器:"
 	},
 	"test": {
-		"random": 0,
 		"pause": "我在此服务器正处于暂停状态。",
 		"text": [
 		],

+ 0 - 1
i18n/zh-hant.json

@@ -355,7 +355,6 @@
 		"bot": "使用這個連結把我添加到其他伺服器:"
 	},
 	"test": {
-		"random": 0,
 		"pause": "我在此伺服器正處於暫停狀態。",
 		"text": [
 		],

+ 9 - 5
util/i18n.js

@@ -18,21 +18,25 @@ class Lang {
 	constructor(lang = defaultSettings.lang, namespace = '') {
 		this.lang = lang;
 		this.namespace = namespace;
-		this.fallback = ( i18n?.[lang]?.fallback.slice() || [defaultSettings.lang] );
+		this.fallback = ( i18n?.[lang]?.fallback.slice() || [defaultSettings.lang] ).filter( fb => fb );
 
 		this.localNames = {};
 		this.aliases = {};
 		let aliases = ( i18n?.[lang]?.aliases || {} );
 		Object.keys(aliases).forEach( cmd => {
-			if ( !( cmd in this.localNames ) ) this.localNames[cmd] = aliases[cmd][0];
+			if ( aliases[cmd][0] && !( cmd in this.localNames ) ) {
+				this.localNames[cmd] = aliases[cmd][0];
+			}
 			aliases[cmd].forEach( alias => {
-				if ( !( alias in this.aliases ) ) this.aliases[alias] = cmd;
+				if ( alias && !( alias in this.aliases ) ) this.aliases[alias] = cmd;
 			} );
 		} );
 		Object.keys(defaultAliases).forEach( cmd => {
-			if ( !( cmd in this.localNames ) ) this.localNames[cmd] = defaultAliases[cmd][0];
+			if ( defaultAliases[cmd][0] && !( cmd in this.localNames ) ) {
+				this.localNames[cmd] = defaultAliases[cmd][0];
+			}
 			defaultAliases[cmd].forEach( alias => {
-				if ( !( alias in this.aliases ) ) this.aliases[alias] = cmd;
+				if ( alias && !( alias in this.aliases ) ) this.aliases[alias] = cmd;
 			} );
 		} );
 	}