| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  | <script lang="ts"> | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Properly renders a translation | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   import { Translation } from "../i18n/Translation" | 
					
						
							|  |  |  |   import { onDestroy } from "svelte" | 
					
						
							|  |  |  |   import Locale from "../i18n/Locale" | 
					
						
							|  |  |  |   import { Utils } from "../../Utils" | 
					
						
							|  |  |  |   import FromHtml from "./FromHtml.svelte" | 
					
						
							|  |  |  |   import WeblateLink from "./WeblateLink.svelte" | 
					
						
							| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   export let t: Translation | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |   export let cls: string = "" | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   export let tags: Record<string, string> | undefined = undefined | 
					
						
							| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  |   // Text for the current language | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   let txt: string | undefined | 
					
						
							| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   $: onDestroy( | 
					
						
							|  |  |  |     Locale.language.addCallbackAndRunD((l) => { | 
					
						
							|  |  |  |       const translation = t?.textFor(l) | 
					
						
							|  |  |  |       if (translation === undefined) { | 
					
						
							|  |  |  |         return | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (tags) { | 
					
						
							|  |  |  |         txt = Utils.SubstituteKeys(txt, tags) | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         txt = translation | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 02:45:34 +02:00
										 |  |  | {#if t} | 
					
						
							| 
									
										
										
										
											2023-05-30 23:45:30 +02:00
										 |  |  |   <span class={cls}> | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |     <FromHtml src={txt} /> | 
					
						
							|  |  |  |     <WeblateLink context={t.context} /> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:45:34 +02:00
										 |  |  |   </span> | 
					
						
							|  |  |  | {/if} |