2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								'use strict' ;  
						 
					
						
							
								
									
										
										
										
											2017-02-17 21:55:19 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 09:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// For tests relating to Transifex configuration, check i18n.js
  
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  assert  =  require ( 'assert' ) ;  
						 
					
						
							
								
									
										
											 
										
											
												Webpack5 (#10311)
* feat: webpack 5 part 1
* fix: gruntfile fixes
* fix: fix taskbar warning
add app.importScript
copy public/src/modules to build folder
* refactor: remove commented old code
* feat: reenable admin
* fix: acp settings pages, fix sortable on manage categories
embedded require in html not allowed
* fix: bundle serialize/deserizeli so plugins dont break
* test: fixe util tests
* test: fix require path
* test: more test fixes
* test: require correct utils module
* test: require correct utils
* test: log stack
* test: fix db require blowing up tests
* test: move and disable bundle test
* refactor: add aliases
* test: disable testing route
* fix: move webpack modules necessary for build, into `dependencies`
* test: fix one more test
remove 500-embed.tpl
* fix: restore use of assets/nodebb.min.js, at least for now
* fix: remove unnecessary line break
* fix: point to proper ACP bundle
* test: maybe fix build test
* test: composer
* refactor: dont need dist
* refactor: more cleanup
use everything from build/public folder
* get rid of conditional import in app.js
* fix: ace
* refactor: cropper alias
* test: lint and test fixes
* lint: fix
* refactor: rename function to app.require
* refactor: go back to using app.require
* chore: use github branch
* chore: use webpack branch
* feat: webpack webinstaller
* feat: add chunkFile name with contenthash
* refactor: move hooks to top
* refactor: get rid of template500Function
* fix(deps): use webpack5 branch of 2factor plugin
* chore: tagging v2.0.0-beta.0 pre-release version :boom: :shipit: :tada: :rocket:
* refactor: disable cache on templates
loadTemplate is called once by benchpress and the result is cache internally
* refactor: add server side helpers.js
* feat: deprecate /plugins shorthand route, closes #10343
* refactor: use build/public for webpack
* test: fix filename
* fix: more specific selector
* lint: ignore
* refactor: fix comments
* test: add debug for random failing test
* refactor: cleanup
remove test page, remove dupe functions in utils.common
* lint: use relative path  for now
* chore: bump prerelease version
* feat: add translateKeys
* fix: optional params
* fix: get rid of extra timeago files
* refactor: cleanup, require timeago locale earlier
remove translator.prepareDOM, it is in header.tpl html tag
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels (#10378)
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels
- Existing hooks are preserved (to be deprecated at a later date, possibly)
- New init hooks are called on NodeBB start, and provide a one-stop shop to add new privileges, instead of having to add to four different hooks
* docs: fix typo in comment
* test: spec changes
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels (#10378)
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels
- Existing hooks are preserved (to be deprecated at a later date, possibly)
- New init hooks are called on NodeBB start, and provide a one-stop shop to add new privileges, instead of having to add to four different hooks
* docs: fix typo in comment
* test: spec changes
* feat: allow app.require('bootbox'/'benchpressjs')
* refactor: require server side utils
* test: jquery ready
* change istaller to use build/public
* test: use document.addEventListener
* refactor: closes #10301
* refactor: generateTopicClass
* fix: column counts for other privileges
* fix: #10443, regression where sorted-list items did not render into the DOM in the predicted order [breaking]
* fix: typo in hook name
* refactor: introduce a generic autocomplete.init() method that can be called to add nodebb-style autocompletion but using different data sources (e.g. not user/groups/tags)
* fix: crash if `delay` not passed in (as it cannot be destructured)
* refactor: replace substr
* feat: set --panel-offset style in html element based on stored value in localStorage
* refactor: addDropupHandler() logic to be less naive
- Take into account height of the menu
- Don't apply dropUp logic if there's nothing in the dropdown
- Remove 'hidden' class (added by default in Persona for post tools) when menu items are added
closes #10423
* refactor: simplify utils.params [breaking]
Retrospective analysis of the usage of this method suggests that the options passed in are superfluous, and that only `url` is required. Using a browser built-in makes more sense to accomplish what this method sets out to do.
* feat: add support for returning full URLSearchParams for utils.params
* fix: utils.params() fallback handling
* fix: default empty obj for params()
* fix: remove \'loggedin\' and \'register\' qs parameters once they have been used, delay invocation of messages until ajaxify.end
* fix: utils.params() not allowing relative paths to be passed in
* refactor(DRY): new assertPasswordValidity utils method
* fix: incorrect error message returned on insufficient privilege on flag edit
* fix: read/update/delete access to flags API should be limited for moderators to only post flags in categories they moderate
- added failing tests and patched up middleware.assert.flags to fix
* refactor: flag api v3 tests to create new post and flags on every round
* fix: missing error:no-flag language key
* refactor: flags.canView to check flag existence, simplify middleware.assert.flag
* feat: flag deletion API endpoint, #10426
* feat: UI for flag deletion, closes #10426
* chore: update plugin versions
* chore: up emoji
* chore: update markdown
* chore: up emoji-android
* fix: regression caused by utils.params() refactor, supports arrays and pipes all values through utils.toType, adjusts tests to type check
Co-authored-by: Julian Lam <julian@nodebb.org>
											 
										 
										
											2022-04-29 21:39:33 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  shim  =  require ( '../src/translator' ) ;  
						 
					
						
							
								
									
										
										
										
											2021-02-03 23:53:16 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 14:10:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  {  Translator  }  =  shim ;  
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  db  =  require ( './mocks/databasemock' ) ;  
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Translator shim' ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( '.translate()' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should translate correctly' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											shim . translate ( '[[global:pagination.out-of, (foobar), [[global:home]]]]' ,  ( 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should accept a language parameter and adjust accordingly' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											shim . translate ( '[[global:home]]' ,  'de' ,  ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:09:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Übersicht' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-16 13:33:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should translate empty string properly' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											shim . translate ( '' ,  'en-GB' ,  ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-16 13:33:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should translate empty string properly' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-16 13:33:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translated  =  await  shim . translate ( '' ,  'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( translated ,  '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-25 12:51:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should not allow path traversal' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  t  =  await  shim . translate ( '[[../../../../config:secret]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( t ,  'secret' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 13:55:40 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( 'translateKeys' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should translate each key in array' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  translated  =  await  shim . translateKeys ( [ '[[global:home]]' ,  '[[global:search]]' ] ,  'en-GB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . deepStrictEqual ( translated ,  [ 'Home' ,  'Search' ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should translate each key in array using a callback' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											shim . translateKeys ( [ '[[global:save]]' ,  '[[global:close]]' ] ,  'en-GB' ,  ( translated )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert . deepStrictEqual ( translated ,  [ 'Save' ,  'Close' ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it ( 'should load translations for language' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shim . load ( 'en-GB' ,  'global' ,  ( translations )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( translations ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( translations [ 'header.profile' ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it ( 'should get translations for language' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shim . getTranslations ( 'en-GB' ,  'global' ,  ( translations )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( translations ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert ( translations [ 'header.profile' ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2016-09-12 13:52:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'new Translator(language)' ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it ( 'should throw if not passed a language' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . throws ( ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											new  Translator ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ,  /language string/ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.translate()' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should handle basic translations' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:home]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys in regular text' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( 'Let\'s go [[global:home]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Let\'s go Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys in regular text with another language specified' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:home]] test' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Übersicht test' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys with parameters' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:pagination.out-of, 1, 5]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '1 out of 5' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys inside language keys' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[notifications:outgoing-link-message, [[global:guest]]]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'You are now leaving Guest' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys inside language keys with multiple parameters' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[notifications:user-posted-to, [[global:guest]], My Topic]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '<strong>Guest</strong> has posted a reply to: <strong>My Topic</strong>' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should handle language keys inside language keys with all parameters as language keys' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[notifications:user-posted-to, [[global:guest]], [[global:guest]]]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-22 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '<strong>Guest</strong> has posted a reply to: <strong>Guest</strong>' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should properly handle parameters that contain square brackets' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:pagination.out-of, [guest], [[global:home]]]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-18 15:48:41 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '[guest] out of Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-22 11:54:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should properly handle parameters that contain parentheses' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[global:pagination.out-of, (foobar), [[global:home]]]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-27 09:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '(foobar) out of Home' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should escape language key parameters with HTML in them' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  key  =  '[[global:403.login, <strong>test</strong>]]' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-07 11:54:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Perhaps you should <a class="alert-link" 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not unescape html in parameters' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 16:14:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  key  =  '[[pages:tag, some&tag]]' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 16:14:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Topics tagged under "some&tag"' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should translate escaped translation arguments properly' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 20:22:46 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// https://github.com/NodeBB/NodeBB/issues/9206
 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 20:22:46 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  key  =  '[[notifications:upvoted-your-post-in, test1, error: Error: [[error:group-name-too-long]] on NodeBB Upgrade]]' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 20:22:46 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  '<strong>test1</strong> has upvoted your post in <strong>error: Error: [[error:group-name-too-long]] on NodeBB Upgrade</strong>.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should properly escape and ignore % and \\, in arguments' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  title  =  'Test 1\\, 2\\, 3 %2 salmon' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  key  =  ` [[topic:composer.replying-to,  ${ title } ]] ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Replying to Test 1, 2, 3 %2 salmon' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not escape regular %' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  title  =  '3 % salmon' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 12:48:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  key  =  ` [[topic:composer.replying-to,  ${ title } ]] ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( key ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'Replying to 3 % salmon' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-25 17:09:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not translate [[derp] some text' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[derp] some text' ) . then ( ( 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not translate [[derp]] some text' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[derp]] some text' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-04 23:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( '[[derp]] some text' ,  translated ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should not translate [[derp:xyz] some text' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[derp:xyz] some text' ) . then ( ( 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should translate keys with slashes properly' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[pages:users/latest]]' ) . then ( ( 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should use key for unknown keys without arguments' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[unknown:key.without.args]]' ) . then ( ( translated )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-12 20:34:31 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert . strictEqual ( translated ,  'key.without.args' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should use backup for unknown keys with arguments' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  translator . translate ( '[[unknown:key.with.args, arguments are here, derpity, derp]]' ) . then ( ( 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should ignore unclosed tokens' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											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 ( ( 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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Translator.create()' ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it ( 'should return an instance of Translator' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  translator  =  Translator . create ( 'en-GB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert ( translator  instanceof  Translator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should return the same object for the same language' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  one  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  two  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										assert . strictEqual ( one ,  two ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should default to defaultLang' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  translator  =  Translator . create ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-12 12:48:43 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Translator modules' ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it ( 'should work before registered' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  translator  =  Translator . create ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 20:35:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Translator . registerModule ( 'test-custom-integer-format' ,  lang  =>  function  ( key ,  args )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  num  =  parseInt ( args [ 0 ] ,  10 )  ||  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( key  ===  'binary' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  num . toString ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( key  ===  'hex' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  num . toString ( 16 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( key  ===  'octal' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  num . toString ( 8 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  num . toString ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  translator . translate ( '[[test-custom-integer-format:octal, 24]]' ) . then ( ( translation )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( translation ,  '30' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'should work after registered' ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  translator  =  Translator . create ( 'de' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  translator . translate ( '[[test-custom-integer-format:octal, 23]]' ) . then ( ( translation )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( translation ,  '27' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									it ( 'registerModule be passed the language' ,  ( done )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Translator . registerModule ( 'something' ,  ( lang )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . ok ( lang ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:06:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  translator  =  Translator . create ( 'fr_FR' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-27 10:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2016-11-28 12:59:41 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( 'Translator static methods' ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									describe ( '.removePatterns' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should remove translator patterns from text' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 12:59:41 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											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 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.escape' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should escape translation patterns within text' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:23:06 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											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 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.unescape' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should unescape escaped translation patterns within text' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											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 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( '.compile' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should create a translator pattern from a key and list of arguments' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-01 17:23:06 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											assert . strictEqual ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Translator . compile ( 'amazing:cool' ,  'awesome' ,  'great' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'[[amazing:cool, awesome, great]]' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											done ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-10 20:41:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( 'should escape `%` and `,` in arguments' ,  ( done )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-10 20:41:49 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 21:50:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( 'add translation' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should add custom translations' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 21:50:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											shim . addTranslation ( 'en-GB' ,  'my-namespace' ,  {  foo :  'a custom translation'  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  t  =  await  shim . translate ( 'this is best [[my-namespace:foo]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( t ,  'this is best a custom translation' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-17 16:06:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									describe ( 'translate nested keys' ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it ( 'should handle nested translations' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-17 16:06:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											shim . addTranslation ( 'en-GB' ,  'my-namespace' ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												key :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													key1 :  'key1 translated' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													key2 :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														key3 :  'key3 translated' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  t1  =  await  shim . translate ( 'this is best [[my-namespace:key.key1]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  t2  =  await  shim . translate ( 'this is best [[my-namespace:key.key2.key3]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( t1 ,  'this is best key1 translated' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( t2 ,  'this is best key3 translated' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 00:01:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										it ( "should try the defaults if it didn't reach a string in a nested translation" ,  async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-17 16:06:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											shim . addTranslation ( 'en-GB' ,  'my-namespace' ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												default1 :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													default1 :  'default1 translated' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'' :  'incorrect priority' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												default2 :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'' :  'default2 translated' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  d1  =  await  shim . translate ( 'this is best [[my-namespace:default1]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  d2  =  await  shim . translate ( 'this is best [[my-namespace:default2]]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( d1 ,  'this is best default1 translated' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											assert . strictEqual ( d2 ,  'this is best default2 translated' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 12:59:41 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;