forked from EVOgeek/Vmeda.Online
		
	MOBILE-2383 lang: Load parent lang if found
This commit is contained in:
		
							parent
							
								
									4d37865068
								
							
						
					
					
						commit
						bb23a319c8
					
				| @ -1412,6 +1412,7 @@ | |||||||
|   "core.openinbrowser": "local_moodlemobileapp", |   "core.openinbrowser": "local_moodlemobileapp", | ||||||
|   "core.othergroups": "group", |   "core.othergroups": "group", | ||||||
|   "core.pagea": "moodle", |   "core.pagea": "moodle", | ||||||
|  |   "core.parentlanguage": "langconfig", | ||||||
|   "core.paymentinstant": "moodle", |   "core.paymentinstant": "moodle", | ||||||
|   "core.percentagenumber": "local_moodlemobileapp", |   "core.percentagenumber": "local_moodlemobileapp", | ||||||
|   "core.phone": "moodle", |   "core.phone": "moodle", | ||||||
|  | |||||||
| @ -174,6 +174,7 @@ | |||||||
|     "openinbrowser": "Open in browser", |     "openinbrowser": "Open in browser", | ||||||
|     "othergroups": "Other groups", |     "othergroups": "Other groups", | ||||||
|     "pagea": "Page {{$a}}", |     "pagea": "Page {{$a}}", | ||||||
|  |     "parentlanguage": "", | ||||||
|     "paymentinstant": "Use the button below to pay and be enrolled within minutes!", |     "paymentinstant": "Use the button below to pay and be enrolled within minutes!", | ||||||
|     "percentagenumber": "{{$a}}%", |     "percentagenumber": "{{$a}}%", | ||||||
|     "phone": "Phone", |     "phone": "Phone", | ||||||
|  | |||||||
| @ -40,8 +40,7 @@ export class CoreLangProvider { | |||||||
| 
 | 
 | ||||||
|         platform.ready().then(() => { |         platform.ready().then(() => { | ||||||
|             this.getCurrentLanguage().then((language) => { |             this.getCurrentLanguage().then((language) => { | ||||||
|                 translate.use(language); |                 this.changeCurrentLanguage(language); | ||||||
|                 moment.locale(language); |  | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
| @ -97,8 +96,31 @@ export class CoreLangProvider { | |||||||
|         // Change the language, resolving the promise when we receive the first value.
 |         // Change the language, resolving the promise when we receive the first value.
 | ||||||
|         promises.push(new Promise((resolve, reject): void => { |         promises.push(new Promise((resolve, reject): void => { | ||||||
|             const subscription = this.translate.use(language).subscribe((data) => { |             const subscription = this.translate.use(language).subscribe((data) => { | ||||||
|  |                 // It's a language override, load the original one first.
 | ||||||
|  |                 const fallbackLang = this.translate.instant('core.parentlanguage'); | ||||||
|  | 
 | ||||||
|  |                 if (fallbackLang != '' && fallbackLang != language) { | ||||||
|  |                     const fallbackSubs = this.translate.use(fallbackLang).subscribe((fallbackData) => { | ||||||
|  |                         data = Object.assign(fallbackData, data); | ||||||
|                         resolve(data); |                         resolve(data); | ||||||
| 
 | 
 | ||||||
|  |                         // Data received, unsubscribe. Use a timeout because we can receive a value immediately.
 | ||||||
|  |                         setTimeout(() => { | ||||||
|  |                             fallbackSubs.unsubscribe(); | ||||||
|  |                         }); | ||||||
|  |                     }, (error) => { | ||||||
|  |                         // Resolve with the original language.
 | ||||||
|  |                         resolve(data); | ||||||
|  | 
 | ||||||
|  |                         // Error received, unsubscribe. Use a timeout because we can receive a value immediately.
 | ||||||
|  |                         setTimeout(() => { | ||||||
|  |                             fallbackSubs.unsubscribe(); | ||||||
|  |                         }); | ||||||
|  |                     }); | ||||||
|  |                 } else { | ||||||
|  |                     resolve(data); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|                 // Data received, unsubscribe. Use a timeout because we can receive a value immediately.
 |                 // Data received, unsubscribe. Use a timeout because we can receive a value immediately.
 | ||||||
|                 setTimeout(() => { |                 setTimeout(() => { | ||||||
|                     subscription.unsubscribe(); |                     subscription.unsubscribe(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user