2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								'use strict' ;  
						 
					
						
							
								
									
										
										
										
											2017-02-17 21:55:19 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-08 11:55:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  assert  =  require ( 'assert' ) ;  
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  shim  =  require ( '../public/src/modules/translator.js' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var  Translator  =  shim . Translator ;  
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  db  =  require ( './mocks/databasemock' ) ;  
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Translator shim' ,  function  ( )  {  
						 
					
						
							
								
									
										
										
										
											2016-10-25 21:34:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.translate()' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 11:43:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should translate correctly' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											shim . translate ( '[[global:pagination.out_of, (foobar), [[global:home]]]]' ,  function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '(foobar) out of Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should accept a language parameter and adjust accordingly' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											shim . translate ( '[[global:home]]' ,  'de' ,  function  ( translated )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Übersicht' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-16 13:33:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should translate empty string properly' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											shim . translate ( '' ,  'en-GB' ,  function  ( translated )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should translate empty string properly' ,  async  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  translated  =  await  shim . translate ( '' ,  'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( translated ,  '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2016-09-12 13:52:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-25 21:34:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'new Translator(language)' ,  function  ( )  {  
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should throw if not passed a language' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . throws ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											new  Translator ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ,  /language string/ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-25 21:34:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.translate()' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle basic translations' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:home]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys in regular text' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( 'Let\'s go [[global:home]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Let\'s go Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys in regular text with another language specified' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:home]] test' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Übersicht test' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys with parameters' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:pagination.out_of, 1, 5]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '1 out of 5' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys inside language keys' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[notifications:outgoing_link_message, [[global:guest]]]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'You are now leaving Guest' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys inside language keys with multiple parameters' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[notifications:user_posted_to, [[global:guest]], My Topic]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '<strong>Guest</strong> has posted a reply to: <strong>My Topic</strong>' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys inside language keys with all parameters as language keys' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[notifications:user_posted_to, [[global:guest]], [[global:guest]]]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-22 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '<strong>Guest</strong> has posted a reply to: <strong>Guest</strong>' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should properly handle parameters that contain square brackets' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:pagination.out_of, [guest], [[global:home]]]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '[guest] out of Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-22 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should properly handle parameters that contain parentheses' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:pagination.out_of, (foobar), [[global:home]]]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 09:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '(foobar) out of Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should escape language key parameters with HTML in them' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-22 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  key  =  '[[global:403.login, <strong>test</strong>]]' ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 09:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Perhaps you should <a href=\'<strong>test</strong>/login\'>try logging in</a>?' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-22 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-08 11:55:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 16:14:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not unescape html in parameters' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  key  =  '[[pages:tag, some&tag]]' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Topics tagged under "some&tag"' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should properly escape and ignore % and \\, in arguments' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  title  =  'Test 1\\, 2\\, 3 %2 salmon' ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-18 01:56:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  key  =  '[[topic:composer.replying_to, '  +  title  +  ']]' ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Replying to Test 1, 2, 3 %2 salmon' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should not escape regular %' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  title  =  '3 % salmon' ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-24 12:46:40 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  key  =  '[[topic:composer.replying_to, '  +  title  +  ']]' ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Replying to 3 % salmon' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-25 17:09:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not translate [[derp] some text' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[derp] some text' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( '[[derp] some text' ,  translated ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-12 11:23:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 11:28:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-02-04 23:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not translate [[derp]] some text' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  translator . translate ( '[[derp]] some text' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( '[[derp]] some text' ,  translated ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not translate [[derp:xyz] some text' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[derp:xyz] some text' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( '[[derp:xyz] some text' ,  translated ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 11:28:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 21:14:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should translate keys with slashes properly' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[pages:users/latest]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 19:45:05 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Latest Users' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 21:14:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-12 20:34:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should use key for unknown keys without arguments' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  translator . translate ( '[[unknown:key.without.args]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'key.without.args' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should use backup for unknown keys with arguments' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  translator . translate ( '[[unknown:key.with.args, arguments are here, derpity, derp]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-13 12:37:54 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'unknown:key.with.args, arguments are here, derpity, derp' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-12 20:34:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should ignore unclosed tokens' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  translator . translate ( 'here is some stuff and other things [[abc:xyz, other random stuff should be fine here [[global:home]] and more things [[pages:users/latest]]' ) . then ( function  ( translated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-13 12:37:54 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'here is some stuff and other things abc:xyz, other random stuff should be fine here Home and more things Latest Users' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-12 20:34:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-25 21:34:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Translator.create()' ,  function  ( )  {  
						 
					
						
							
								
									
										
										
										
											2016-10-13 11:43:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should return an instance of Translator' ,  function  ( done )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( translator  instanceof  Translator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 11:43:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should return the same object for the same language' ,  function  ( done )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  one  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  two  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( one ,  two ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 11:43:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should default to defaultLang' ,  function  ( done )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  translator  =  Translator . create ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 09:50:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										assert . strictEqual ( translator . lang ,  'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								describe ( 'Translator modules' ,  function  ( )  {  
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should work before registered' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  translator  =  Translator . create ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Translator . registerModule ( 'test-custom-integer-format' ,  function  ( lang )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  function  ( key ,  args )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												var  num  =  parseInt ( args [ 0 ] ,  10 )  ||  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( key  ===  'binary' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													return  num . toString ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( key  ===  'hex' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													return  num . toString ( 16 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( key  ===  'octal' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													return  num . toString ( 8 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  num . toString ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  translator . translate ( '[[test-custom-integer-format:octal, 24]]' ) . then ( function  ( translation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( translation ,  '30' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should work after registered' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  translator  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  translator . translate ( '[[test-custom-integer-format:octal, 23]]' ) . then ( function  ( translation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( translation ,  '27' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it ( 'registerModule be passed the language' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Translator . registerModule ( 'something' ,  function  ( lang )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . ok ( lang ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  translator  =  Translator . create ( 'fr_FR' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2016-11-28 12:59:41 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								describe ( 'Translator static methods' ,  function  ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( '.removePatterns' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should remove translator patterns from text' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . removePatterns ( 'Lorem ipsum dolor [[sit:amet]], consectetur adipiscing elit. [[sed:vitae, [[semper:dolor]]]] lorem' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'Lorem ipsum dolor , consectetur adipiscing elit.  lorem' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:23:06 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.escape' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should escape translation patterns within text' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . escape ( 'some nice text [[global:home]] here' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-13 12:37:54 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												'some nice text [[global:home]] here' 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:23:06 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( '.unescape' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should unescape escaped translation patterns within text' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . unescape ( 'some nice text \\[\\[global:home\\]\\] here' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'some nice text [[global:home]] here' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-13 12:37:54 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . unescape ( 'some nice text [[global:home]] here' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'some nice text [[global:home]] here' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:23:06 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( '.compile' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should create a translator pattern from a key and list of arguments' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . compile ( 'amazing:cool' ,  'awesome' ,  'great' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'[[amazing:cool, awesome, great]]' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-10 20:41:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should escape `%` and `,` in arguments' ,  function  ( done )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . compile ( 'amazing:cool' ,  '100% awesome!' ,  'one, two, and three' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'[[amazing:cool, 100% awesome!, one, two, and three]]' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:23:06 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 12:59:41 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;