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") { |         if (typeof (json) === "string") { | ||||||
|             return new Translation({"*": json}); |             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 = {}; |         const tr = {}; | ||||||
|         let keyCount = 0; |         let keyCount = 0; | ||||||
|         for (let key in json) { |         for (let key in json) { | ||||||
|  |  | ||||||
|  | @ -45,7 +45,8 @@ | ||||||
|         "nl": "Is deze drinkwaterkraan nog steeds werkende?" |         "nl": "Is deze drinkwaterkraan nog steeds werkende?" | ||||||
|       }, |       }, | ||||||
|       "render": { |       "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": { |       "freeform": { | ||||||
|         "key": "operational_status" |         "key": "operational_status" | ||||||
|  |  | ||||||
|  | @ -18,8 +18,8 @@ | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   "description": { |   "description": { | ||||||
|     "en": "", |     "en": "A map, meant for tourists which is permanently installed in the public space", | ||||||
|     "nl": "" |     "nl": "Een permantent geinstalleerde kaart" | ||||||
|   }, |   }, | ||||||
|   "tagRenderings": [ |   "tagRenderings": [ | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -23,10 +23,8 @@ | ||||||
|     { |     { | ||||||
|       "id": "Toilet", |       "id": "Toilet", | ||||||
|       "name": { |       "name": { | ||||||
|         "render": { |         "en": "Toilets", | ||||||
|           "en": "Toilets", |         "de": "Toiletten" | ||||||
|           "de": "Toiletten" |  | ||||||
|         } |  | ||||||
|       }, |       }, | ||||||
|       "overpassTags": "amenity=toilets", |       "overpassTags": "amenity=toilets", | ||||||
|       "title": { |       "title": { | ||||||
|  | @ -59,10 +57,8 @@ | ||||||
|             "amenity=toilets" |             "amenity=toilets" | ||||||
|           ], |           ], | ||||||
|           "description": { |           "description": { | ||||||
|             "render": { |  | ||||||
|               "en": "A publicly accessible toilet or restroom", |               "en": "A publicly accessible toilet or restroom", | ||||||
|               "de": "Eine öffentlich zugängliche Toilette" |               "de": "Eine öffentlich zugängliche Toilette" | ||||||
|             } |  | ||||||
|           } |           } | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|  |  | ||||||
|  | @ -45,9 +45,13 @@ function validate(layout: Layout) { | ||||||
|         missing[ln] = 0; |         missing[ln] = 0; | ||||||
|         present[ln] = 0; |         present[ln] = 0; | ||||||
|         for (const translation of translations) { |         for (const translation of translations) { | ||||||
|  |             if (translation.translations["*"] !== undefined) { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|             const txt = translation.translations[ln]; |             const txt = translation.translations[ln]; | ||||||
|             const isMissing = txt === undefined || txt === "" || txt.toLowerCase().indexOf("todo") >= 0; |             const isMissing = txt === undefined || txt === "" || txt.toLowerCase().indexOf("todo") >= 0; | ||||||
|             if (isMissing) { |             if (isMissing) { | ||||||
|  |                 console.log(`   ${layout.id}: No translation for`, ln, "in", translation.translations, "got:", txt) | ||||||
|                 missing[ln]++ |                 missing[ln]++ | ||||||
|             } else { |             } else { | ||||||
|                 present[ln]++; |                 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) { |     for (const ln of layout.supportedLanguages) { | ||||||
|         const amiss = missing[ln]; |         const amiss = missing[ln]; | ||||||
|         const ok = present[ln]; |         const ok = present[ln]; | ||||||
|         const total = amiss + ok; |         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); |     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") | console.log("Counting all translations") | ||||||
| Translations.CountTranslations(); | Translations.CountTranslations(); | ||||||
| console.log("All done!"); | console.log("All done!"); | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue