forked from MapComplete/MapComplete
		
	Show fixlink in translation script
This commit is contained in:
		
							parent
							
								
									d3b245adf0
								
							
						
					
					
						commit
						275b51ee99
					
				
					 1 changed files with 10 additions and 9 deletions
				
			
		|  | @ -225,12 +225,18 @@ class TranslationPart { | ||||||
|                 if (typeof value !== "string") { |                 if (typeof value !== "string") { | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|                  |                 let [_, __, weblatepart, lang] = key.split("/") | ||||||
|  |                 if (lang === undefined) { | ||||||
|  |                     // This is a core translation, it has one less path segment
 | ||||||
|  |                     lang = weblatepart | ||||||
|  |                     weblatepart = "core" | ||||||
|  |                 } | ||||||
|  |                 const fixLink = `Fix it on https://hosted.weblate.org/translate/mapcomplete/${weblatepart}/${lang}/?offset=1&q=context%3A%3D%22${encodeURIComponent( path.join("."))}%22`; | ||||||
|                 let subparts: string[] = value.match(/{[^}]*}/g) |                 let subparts: string[] = value.match(/{[^}]*}/g) | ||||||
|                 if (subparts === null) { |                 if (subparts === null) { | ||||||
|                     if (neededSubparts.size > 0) { |                     if (neededSubparts.size > 0) { | ||||||
|                         errors.push({ |                         errors.push({ | ||||||
|                             error: "The translation for " + key + " does not have any subparts, but expected " + Array.from(neededSubparts).map(part => part.part +" (used in "+part.usedByLanguage+")").join(",") + " . The full translation is " + value, |                             error: "The translation for " + key + " does not have any subparts, but expected " + Array.from(neededSubparts).map(part => part.part +" (used in "+part.usedByLanguage+")").join(",") + " . The full translation is " + value+"\n"+fixLink, | ||||||
|                             path: path |                             path: path | ||||||
|                         }) |                         }) | ||||||
|                     } |                     } | ||||||
|  | @ -238,17 +244,12 @@ class TranslationPart { | ||||||
|                 } |                 } | ||||||
|                 subparts = subparts.map(p => p.split(/\(.*\)/)[0]) |                 subparts = subparts.map(p => p.split(/\(.*\)/)[0]) | ||||||
|                 if (subparts.indexOf(part) < 0) { |                 if (subparts.indexOf(part) < 0) { | ||||||
|                     let [_, __, weblatepart, lang] = key.split("/") |           | ||||||
|                     if (lang === undefined) { |  | ||||||
|                         // This is a core translation, it has one less path segment
 |  | ||||||
|                         lang = weblatepart |  | ||||||
|                         weblatepart = "core" |  | ||||||
|                     } |  | ||||||
|                     if(lang === "en" || usedByLanguage === "en"){ |                     if(lang === "en" || usedByLanguage === "en"){ | ||||||
|                         errors.push({ |                         errors.push({ | ||||||
|                             error: `The translation for ${key} does not have the required subpart ${part}.
 |                             error: `The translation for ${key} does not have the required subpart ${part}.
 | ||||||
|     \tThe full translation is ${value} |     \tThe full translation is ${value} | ||||||
|     \tFix it on https://hosted.weblate.org/translate/mapcomplete/${weblatepart}/${lang}/?offset=1&q=context%3A%3D%22${encodeURIComponent( path.join("."))}%22`,
 |     \t${fixLink}`,
 | ||||||
|                             path: path |                             path: path | ||||||
|                         }) |                         }) | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue