forked from EVOgeek/Vmeda.Online
		
	MOBILE-4288 multilang: Clean up
This commit is contained in:
		
							parent
							
								
									c3bd315355
								
							
						
					
					
						commit
						b52deca5fe
					
				| @ -21,7 +21,7 @@ import { CoreSite } from '@classes/site'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to support the Multilang filter. | ||||
|  * Handler to support the Multilang filter in core. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonFilterMultilangHandlerService extends CoreFilterDefaultHandler { | ||||
|  | ||||
| @ -19,7 +19,9 @@ import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/def | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to support the Multilang filter. | ||||
|  * Handler to support the multilang2 community filter. | ||||
|  * | ||||
|  * @see https://moodle.org/plugins/filter_multilang2
 | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonFilterMultilang2HandlerService extends CoreFilterDefaultHandler { | ||||
|  | ||||
| @ -12,11 +12,9 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { AddonFilterMultilangHandler } from '@addons/filter/multilang/services/handlers/multilang'; | ||||
| import { AddonFilterMultilang2Handler } from '@addons/filter/multilang2/services/handlers/multilang2'; | ||||
| import { Component, Input, OnInit, Type } from '@angular/core'; | ||||
| import { FormGroup } from '@angular/forms'; | ||||
| 
 | ||||
| import { CoreLang } from '@services/lang'; | ||||
| import { AuthEmailSignupProfileField } from '@features/login/services/login-helper'; | ||||
| import { CoreUserProfileField } from '@features/user/services/user'; | ||||
| import { CoreUserProfileFieldDelegate } from '@features/user/services/user-profile-field-delegate'; | ||||
| @ -54,8 +52,7 @@ export class CoreUserProfileFieldComponent implements OnInit { | ||||
|         this.componentClass = await CoreUserProfileFieldDelegate.getComponent(this.field, this.signup); | ||||
| 
 | ||||
|         if ('param1' in this.field && this.field.param1) { | ||||
|             this.field.param1 = await AddonFilterMultilangHandler.filter(<string> this.field.param1); | ||||
|             this.field.param1 = await AddonFilterMultilang2Handler.filter(<string> this.field.param1); | ||||
|             this.field.param1 = await CoreLang.filterMultilang(<string> this.field.param1); | ||||
|         } | ||||
| 
 | ||||
|         this.data.field = this.field; | ||||
|  | ||||
| @ -24,6 +24,8 @@ import { makeSingleton, Translate, Http } from '@singletons'; | ||||
| import moment from 'moment-timezone'; | ||||
| import { CoreSite } from '../classes/site'; | ||||
| import { CorePlatform } from '@services/platform'; | ||||
| import { AddonFilterMultilangHandler } from '@addons/filter/multilang/services/handlers/multilang'; | ||||
| import { AddonFilterMultilang2Handler } from '@addons/filter/multilang2/services/handlers/multilang2'; | ||||
| 
 | ||||
| /* | ||||
|  * Service to handle language features, like changing the current language. | ||||
| @ -516,6 +518,18 @@ export class CoreLangProvider { | ||||
|         return <Record<string, string>> await observable.toPromise(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Filter a multilang string. | ||||
|      * | ||||
|      * @param text Multilang string. | ||||
|      * @returns Filtered string. | ||||
|      */ | ||||
|     async filterMultilang(text: string): Promise<string> { | ||||
|         return Promise.resolve(text) | ||||
|             .then(text => AddonFilterMultilangHandler.filter(text)) | ||||
|             .then(text => AddonFilterMultilang2Handler.filter(text)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Unload custom or site plugin strings, removing them from the translations table. | ||||
|      * | ||||
|  | ||||
| @ -46,7 +46,6 @@ import { CoreViewerImageComponent } from '@features/viewer/components/image/imag | ||||
| import { CoreFormFields, CoreForms } from '../../singletons/form'; | ||||
| import { CoreModalLateralTransitionEnter, CoreModalLateralTransitionLeave } from '@classes/modal-lateral-transition'; | ||||
| import { CoreZoomLevel } from '@features/settings/services/settings-helper'; | ||||
| import { AddonFilterMultilangHandler } from '@addons/filter/multilang/services/handlers/multilang'; | ||||
| import { CoreSites } from '@services/sites'; | ||||
| import { NavigationStart } from '@angular/router'; | ||||
| import { filter } from 'rxjs/operators'; | ||||
| @ -58,8 +57,8 @@ import { CoreSiteError } from '@classes/errors/siteerror'; | ||||
| import { CoreUserSupport } from '@features/user/services/support'; | ||||
| import { CoreErrorInfoComponent } from '@components/error-info/error-info'; | ||||
| import { CorePlatform } from '@services/platform'; | ||||
| import { AddonFilterMultilang2Handler } from '@addons/filter/multilang2/services/handlers/multilang2'; | ||||
| import { CoreCancellablePromise } from '@classes/cancellable-promise'; | ||||
| import { CoreLang } from '@services/lang'; | ||||
| 
 | ||||
| /* | ||||
|  * "Utils" service with helper functions for UI, DOM elements and HTML code. | ||||
| @ -1171,8 +1170,7 @@ export class CoreDomUtilsProvider { | ||||
| 
 | ||||
|         if (hasHTMLTags && !CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.7')) { | ||||
|             // Treat multilang.
 | ||||
|             options.message = await AddonFilterMultilangHandler.filter(<string> options.message); | ||||
|             options.message = await AddonFilterMultilang2Handler.filter(<string> options.message); | ||||
|             options.message = await CoreLang.filterMultilang(<string> options.message); | ||||
|         } | ||||
| 
 | ||||
|         const alertId = <string> Md5.hashAsciiStr((options.header || '') + '#' + (options.message || '')); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user