~trans now properly throws an error if language is invalid
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
				
			|||||||
using Newtonsoft.Json.Linq;
 | 
					using System;
 | 
				
			||||||
 | 
					using Newtonsoft.Json.Linq;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Net;
 | 
					using System.Net;
 | 
				
			||||||
@@ -155,6 +156,11 @@ namespace NadekoBot.Modules.Searches
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            string text;
 | 
					            string text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(!_languageDictionary.ContainsKey(sourceLanguage) || 
 | 
				
			||||||
 | 
					               !_languageDictionary.ContainsKey(targetLanguage))
 | 
				
			||||||
 | 
					                throw new ArgumentException();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var url = string.Format("https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}",
 | 
					            var url = string.Format("https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}",
 | 
				
			||||||
                                        ConvertToLanguageCode(sourceLanguage),
 | 
					                                        ConvertToLanguageCode(sourceLanguage),
 | 
				
			||||||
                                        ConvertToLanguageCode(targetLanguage),
 | 
					                                        ConvertToLanguageCode(targetLanguage),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user