forked from MapComplete/MapComplete
		
	Refactoring: use more accurate context in conversion, fix tests
This commit is contained in:
		
							parent
							
								
									86d0de3806
								
							
						
					
					
						commit
						f77d99f8ed
					
				
					 43 changed files with 999 additions and 367 deletions
				
			
		| 
						 | 
				
			
			@ -27,14 +27,14 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
 | 
			
		|||
     *       }
 | 
			
		||||
     *   ]
 | 
			
		||||
     * }
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convert(theme, "context").result
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convertStrict(theme, ConversionContext.test())
 | 
			
		||||
     * const expected = {
 | 
			
		||||
     *   layers: [
 | 
			
		||||
     *       {
 | 
			
		||||
     *           builtin: ["abc"],
 | 
			
		||||
     *           override: {
 | 
			
		||||
     *               title:{
 | 
			
		||||
     *                  _context: "prefix:context.layers.0.override.title"
 | 
			
		||||
     *                  _context: "prefix:layers.0.override.title"
 | 
			
		||||
     *                   en: "Some title"
 | 
			
		||||
     *               }
 | 
			
		||||
     *           }
 | 
			
		||||
| 
						 | 
				
			
			@ -57,14 +57,14 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
 | 
			
		|||
     *       }
 | 
			
		||||
     *   ]
 | 
			
		||||
     * }
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convert(theme, "context").result
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convertStrict(theme, ConversionContext.test())
 | 
			
		||||
     * const expected = {
 | 
			
		||||
     *   layers: [
 | 
			
		||||
     *       {
 | 
			
		||||
     *           tagRenderings:[
 | 
			
		||||
     *               {id: "some-tr",
 | 
			
		||||
     *               question:{
 | 
			
		||||
     *                  _context: "prefix:context.layers.0.tagRenderings.some-tr.question"
 | 
			
		||||
     *                  _context: "prefix:layers.0.tagRenderings.some-tr.question"
 | 
			
		||||
     *                   en:"Question?"
 | 
			
		||||
     *               }
 | 
			
		||||
     *               }
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
 | 
			
		|||
     *       }
 | 
			
		||||
     *   ]
 | 
			
		||||
     * }
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convert(theme, "context").result
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convertStrict(theme, ConversionContext.test())
 | 
			
		||||
     * const expected = {
 | 
			
		||||
     *   layers: [
 | 
			
		||||
     *       {
 | 
			
		||||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
 | 
			
		|||
     *       }
 | 
			
		||||
     *   ]
 | 
			
		||||
     * }
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convert(theme, "context").result
 | 
			
		||||
     * const rewritten = new AddContextToTranslations<any>("prefix:").convertStrict(theme, ConversionContext.test())
 | 
			
		||||
     * rewritten // => theme
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +139,10 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
 | 
			
		|||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    return { ...leaf, _context: this._prefix + context + "." + path.join(".") }
 | 
			
		||||
                    return {
 | 
			
		||||
                        ...leaf,
 | 
			
		||||
                        _context: this._prefix + context.path.concat(path).join("."),
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    return leaf
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue