2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  UIEventSource  }  from  "../../Logic/UIEventSource"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  LocalStorageSource  }  from  "../../Logic/Web/LocalStorageSource"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  Utils  }  from  "../../Utils"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  QueryParameters  }  from  "../../Logic/Web/QueryParameters"  
						 
					
						
							
								
									
										
										
										
											2020-07-20 12:39:43 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								export  default  class  Locale  {  
						 
					
						
							
								
									
										
										
										
											2022-04-03 03:00:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  showLinkToWeblate : UIEventSource < boolean >  =  new  UIEventSource < boolean > ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-09 02:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Indicates  that  - if  showLinkToWeblate  is  true -  a  link  on  mobile  mode  is  shown  as  well 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    public  static  showLinkOnMobile : UIEventSource < boolean >  =  new  UIEventSource < boolean > ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 04:58:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  language : UIEventSource < string >  =  Locale . setup ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-25 18:00:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 04:58:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  static  setup() { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 00:15:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  browserLanguage  =  "en" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( typeof  navigator  !==  "undefined" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            browserLanguage  =  navigator . languages ? . [ 0 ]  ? ?  navigator . language  ? ?  "en" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  source  =  LocalStorageSource . Get ( "language" ,  browserLanguage ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-06 02:21:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! Utils . runningFromConsole )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 17:11:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // @ts-ignore
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            window . setLanguage  =  function  ( language : string )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                source . setData ( language ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 03:49:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 00:15:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( QueryParameters . wasInitialized ( "language" ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  qp  =  QueryParameters . GetQueryParameter ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 03:49:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "language" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                undefined , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "The language to display mapcomplete in. Will be ignored in case a logged-in-user did set their language before. If the specified language does not exist, it will default to the first language in the theme." 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            Locale . language . setData ( qp . data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 03:49:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        QueryParameters . GetBooleanQueryParameter ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "fs-translation-mode" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "If set, will show a translation button next to every string." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) . addCallbackAndRunD ( ( tr )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            Locale . showLinkToWeblate . setData ( Locale . showLinkToWeblate . data  ||  tr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 03:00:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 04:58:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  source 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-25 18:00:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-20 12:39:43 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}