forked from MapComplete/MapComplete
		
	Merge develop
This commit is contained in:
		
						commit
						07bc5d6a6d
					
				
					 88 changed files with 3284 additions and 2363 deletions
				
			
		|  | @ -145,7 +145,7 @@ class LayerOverviewUtils { | |||
|                 } | ||||
|             } | ||||
|              | ||||
|             const referencedLayers = Utils.NoNull(themeFile.layers.map(layer => { | ||||
|             const referencedLayers = Utils.NoNull([].concat(...themeFile.layers.map(layer => { | ||||
|                 if(typeof  layer === "string"){ | ||||
|                     return layer | ||||
|                 } | ||||
|  | @ -153,7 +153,12 @@ class LayerOverviewUtils { | |||
|                     return layer["builtin"] | ||||
|                 } | ||||
|                 return undefined | ||||
|             })) | ||||
|             }).map(layerName => { | ||||
|                 if(typeof layerName === "string"){ | ||||
|                     return [layerName] | ||||
|                 } | ||||
|                 return layerName | ||||
|             }))) | ||||
| 
 | ||||
|             themeFile.layers = themeFile.layers | ||||
|                 .filter(l => typeof l != "string") // We remove all the builtin layer references as they don't work with ts-node for some weird reason
 | ||||
|  | @ -172,7 +177,8 @@ class LayerOverviewUtils { | |||
|                 const neededLanguages = themeFile["mustHaveLanguage"] | ||||
|                 if (neededLanguages !== undefined) { | ||||
|                     console.log("Checking language requerements for ", theme.id, "as it must have", neededLanguages.join(", ")) | ||||
|                     const allTranslations = [].concat(Translation.ExtractAllTranslationsFrom(theme, theme.id),   ...referencedLayers.map(layerId => Translation.ExtractAllTranslationsFrom(knownLayerIds.get(layerId), theme.id+"->"+layerId))) | ||||
|                     const allTranslations = [].concat(Translation.ExtractAllTranslationsFrom(theme, theme.id),   | ||||
|                         ...referencedLayers.map(layerId => Translation.ExtractAllTranslationsFrom(knownLayerIds.get(layerId), theme.id+"->"+layerId))) | ||||
|                     for (const neededLanguage of neededLanguages) { | ||||
|                         allTranslations | ||||
|                             .filter(t => t.tr.translations[neededLanguage] === undefined && t.tr.translations["*"] === undefined) | ||||
|  |  | |||
|  | @ -33,7 +33,7 @@ class TranslationPart { | |||
|             } | ||||
|             const v = translations[translationsKey] | ||||
|             if (typeof (v) != "string") { | ||||
|                 console.error("Non-string object in translation while trying to add more translations to '", translationsKey ,"': ", v) | ||||
|                 console.error("Non-string object in translation while trying to add more translations to '", translationsKey, "': ", v) | ||||
|                 throw "Error in an object depicting a translation: a non-string object was found. (" + context + ")\n    You probably put some other section accidentally in the translation" | ||||
|             } | ||||
|             this.contents.set(translationsKey, v) | ||||
|  | @ -166,7 +166,13 @@ function transformTranslation(obj: any, depth = 1) { | |||
|         if (key.match("^[a-zA-Z0-9_]*$") === null) { | ||||
|             throw "Invalid character in key: " + key | ||||
|         } | ||||
|         values += (Utils.Times((_) => "  ", depth)) + key + ": " + transformTranslation(obj[key], depth + 1) + ",\n" | ||||
|         const value = obj[key] | ||||
| 
 | ||||
|         if (isTranslation(value)) { | ||||
|             values += (Utils.Times((_) => "  ", depth)) + "get " + key + "() { return new Translation(" + JSON.stringify(value) + ") }" + ",\n" | ||||
|         } else { | ||||
|             values += (Utils.Times((_) => "  ", depth)) + key + ": " + transformTranslation(value, depth + 1) + ",\n" | ||||
|         } | ||||
|     } | ||||
|     return `{${values}}`; | ||||
| 
 | ||||
|  | @ -300,9 +306,9 @@ function MergeTranslation(source: any, target: any, language: string, context: s | |||
|         } | ||||
|         if (typeof sourceV === "object") { | ||||
|             if (targetV === undefined) { | ||||
|                 try{ | ||||
|                 target[language] = sourceV; | ||||
|                 }catch(e){ | ||||
|                 try { | ||||
|                     target[language] = sourceV; | ||||
|                 } catch (e) { | ||||
|                     throw `At context${context}: Could not add a translation in language ${language} due to ${e}` | ||||
|                 } | ||||
|             } else { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue