forked from MapComplete/MapComplete
		
	Improvements to translation checking in createLayouts, small translation fixes
This commit is contained in:
		
							parent
							
								
									60c835fdac
								
							
						
					
					
						commit
						1eddabd8c9
					
				
					 5 changed files with 30 additions and 12 deletions
				
			
		|  | @ -104,6 +104,10 @@ export class FromJSON { | |||
|         if (typeof (json) === "string") { | ||||
|             return new Translation({"*": json}); | ||||
|         } | ||||
|         if(json.render !== undefined){ | ||||
|             console.error("Using a 'render' where a translation is expected. Content is", json.render); | ||||
|             throw "ERROR: using a 'render' where none is expected" | ||||
|         } | ||||
|         const tr = {}; | ||||
|         let keyCount = 0; | ||||
|         for (let key in json) { | ||||
|  |  | |||
|  | @ -45,7 +45,8 @@ | |||
|         "nl": "Is deze drinkwaterkraan nog steeds werkende?" | ||||
|       }, | ||||
|       "render": { | ||||
|         "en": "The operational status is <i>{operational_status</i>" | ||||
|         "en": "The operational status is <i>{operational_status</i>", | ||||
|         "nl": "Deze waterkraan-status is <i>{operational_status}</i>" | ||||
|       }, | ||||
|       "freeform": { | ||||
|         "key": "operational_status" | ||||
|  |  | |||
|  | @ -18,8 +18,8 @@ | |||
|     } | ||||
|   }, | ||||
|   "description": { | ||||
|     "en": "", | ||||
|     "nl": "" | ||||
|     "en": "A map, meant for tourists which is permanently installed in the public space", | ||||
|     "nl": "Een permantent geinstalleerde kaart" | ||||
|   }, | ||||
|   "tagRenderings": [ | ||||
|     { | ||||
|  |  | |||
|  | @ -23,10 +23,8 @@ | |||
|     { | ||||
|       "id": "Toilet", | ||||
|       "name": { | ||||
|         "render": { | ||||
|           "en": "Toilets", | ||||
|           "de": "Toiletten" | ||||
|         } | ||||
|         "en": "Toilets", | ||||
|         "de": "Toiletten" | ||||
|       }, | ||||
|       "overpassTags": "amenity=toilets", | ||||
|       "title": { | ||||
|  | @ -59,10 +57,8 @@ | |||
|             "amenity=toilets" | ||||
|           ], | ||||
|           "description": { | ||||
|             "render": { | ||||
|               "en": "A publicly accessible toilet or restroom", | ||||
|               "de": "Eine öffentlich zugängliche Toilette" | ||||
|             } | ||||
|           } | ||||
|         }, | ||||
|         { | ||||
|  |  | |||
|  | @ -45,9 +45,13 @@ function validate(layout: Layout) { | |||
|         missing[ln] = 0; | ||||
|         present[ln] = 0; | ||||
|         for (const translation of translations) { | ||||
|             if (translation.translations["*"] !== undefined) { | ||||
|                 continue; | ||||
|             } | ||||
|             const txt = translation.translations[ln]; | ||||
|             const isMissing = txt === undefined || txt === "" || txt.toLowerCase().indexOf("todo") >= 0; | ||||
|             if (isMissing) { | ||||
|                 console.log(`   ${layout.id}: No translation for`, ln, "in", translation.translations, "got:", txt) | ||||
|                 missing[ln]++ | ||||
|             } else { | ||||
|                 present[ln]++; | ||||
|  | @ -55,12 +59,21 @@ function validate(layout: Layout) { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     console.log("Translation completenes for theme", layout.id); | ||||
|     let message = `Translation completenes for theme ${layout.id}` | ||||
|     let isComplete = true; | ||||
|     for (const ln of layout.supportedLanguages) { | ||||
|         const amiss = missing[ln]; | ||||
|         const ok = present[ln]; | ||||
|         const total = amiss + ok; | ||||
|         console.log(`${ln}: ${ok}/${total}`) | ||||
|         message += `\n${ln}: ${ok}/${total}` | ||||
|         if (ok !== total) { | ||||
|             isComplete = false; | ||||
|         } | ||||
|     } | ||||
|     if (isComplete) { | ||||
|         console.log(`${layout.id} is fully translated!`) | ||||
|     } else { | ||||
|         console.log(message) | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -242,7 +255,11 @@ for (const layoutName in all) { | |||
|      | ||||
|     wikiPage += "\n\n"+generateWikiEntry(layout); | ||||
| } | ||||
| writeFile("wikiIndex", wikiPage, (err) => {err ?? console.log("Could not save wikiindex", err)}); | ||||
| writeFile("wikiIndex", wikiPage, (err) => { | ||||
|     if (err !== null) { | ||||
|         console.log("Could not save wikiindex", err); | ||||
|     } | ||||
| }); | ||||
| console.log("Counting all translations") | ||||
| Translations.CountTranslations(); | ||||
| console.log("All done!"); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue