Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { TranslationService } from './translation.service';
- @Injectable()
- export class DictionaryService {
- public static add_cart: string = DictionaryService.getText('add_cart');
- public static adults: string = DictionaryService.getText('adults');
- public static before: string = DictionaryService.getText('before');
- public static breadcrumb_1: string = DictionaryService.getText('breadcrumb_1');
- public static breadcrumb_2: string = DictionaryService.getText('breadcrumb_2');
- public static breadcrumb_3: string = DictionaryService.getText('breadcrumb_3');
- public static breadcrumb_4: string = DictionaryService.getText('breadcrumb_4');
- public static children: string = DictionaryService.getText('children');
- public static children_age: string = DictionaryService.getText('children_age');
- public static continue: string = DictionaryService.getText('continue');
- public static date: string = DictionaryService.getText('date');
- public static discount_coupon_placeholder: string = DictionaryService.getText('discount_coupon_placeholder');
- public static discount_coupon_text: string = DictionaryService.getText('discount_coupon_text');
- public static email: string = DictionaryService.getText('email');
- public static final_price: string = DictionaryService.getText('final_price');
- public static footer_contact: string = DictionaryService.getText('footer_contact');
- public static footer_privacy: string = DictionaryService.getText('footer_privacy');
- public static footer_rights: string = DictionaryService.getText('footer_rights');
- public static footer_terms: string = DictionaryService.getText('footer_terms');
- public static header_secure: string = DictionaryService.getText('header_secure');
- public static header_title: string = DictionaryService.getText('header_title');
- public static invoice: string = DictionaryService.getText('invoice');
- public static nameinput: string = DictionaryService.getText('name');
- public static order_message_1: string = DictionaryService.getText('order_message_1');
- public static order_message_2: string = DictionaryService.getText('order_message_2');
- public static pay_now: string = DictionaryService.getText('pay_now');
- public static payments_methods: string = DictionaryService.getText('payments_methods');
- public static personal_information: string = DictionaryService.getText('personal_information');
- public static price: string = DictionaryService.getText('price');
- public static print_tickets: string = DictionaryService.getText('print_tickets');
- public static quantity: string = DictionaryService.getText('quantity');
- public static summary: string = DictionaryService.getText('summary');
- public static surname: string = DictionaryService.getText('surname');
- public static taxes_text: string = DictionaryService.getText('taxes_text');
- public static terms_read: string = DictionaryService.getText('terms_read');
- public static thank_you: string = DictionaryService.getText('thank_you');
- public static thank_you_order: string = DictionaryService.getText('thank_you_order');
- public static total_cost: string = DictionaryService.getText('total_cost');
- public static unity_price: string = DictionaryService.getText('unity_price');
- public static you_save: string = DictionaryService.getText('you_save');
- public static your_options: string = DictionaryService.getText('your_options');
- constructor(private translationService: TranslationService) {
- }
- public static getTranslations() {
- const arr = JSON.parse(localStorage.getItem('translation')) || null;
- if (arr == null) {
- new TranslationService().readTranslations(this.callback);
- } else {
- return arr;
- }
- }
- static callback = (item: any) => {
- localStorage.setItem('translation', JSON.stringify(item));
- window.location.reload();
- }
- public static getText(search: string): string {
- const lang = localStorage.getItem('lang') || 'EN';
- const arr = this.getTranslations();
- const word = arr.filter(function(x) {
- if (x.Identifier === search) {
- return x;
- }
- });
- if (lang === 'ES') {
- return word[0].Spanish;
- } else {
- return word[0].English;
- }
- }
- }
- // WEBPACK FOOTER //
- // ./src/app/service/dictionary.service.ts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement