خطای Ionic 2 RC0 و Angular 2 آخرین نسخه هنگام ساخت اندروید (ngc: خطا: خطا هنگام حل مقادیر نماد به صورت ایستا)


خطا ظاهر میشود زمانی که من اندروید را با استفاده از دستور ionic build android بسازم

ngc: خطا: خطا در حل مقادیر نماد به صورت ایستا مواجه شد. ارجاع به یک نماد محلی (غیر صادر شده) 'dictionary'. در نظر بگیرید نماد را صادر کنید (موقعیت 14:8 در فایل .ts اصلی)، حل نماد TRANSLATION_PROVIDERS

کد من در فایل translation.ts

export const TRANSLATIONS = new OpaqueToken('translations');
// all traslations
 const dictionary : any = {
    [LANG_EN_NAME]: LANG_EN_TRANS,
    [LANG_AR_NAME]: LANG_AR_TRANS,
    [LANG_FR_NAME]: LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS : any = [
    { provide: TRANSLATIONS, useValue: dictionary},
];

کد app.module.ts من

import {TRANSLATION_PROVIDERS,TranslatePipe,TranslateService} from './translate';

@NgModule({
  declarations: [
    MyApp,
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,

  ],
  providers: [TRANSLATION_PROVIDERS,TranslateService ]
})
export class AppModule {}

هر پیشنهادی در مورد این مسئله، راستی وقتی که از دستور ionic serve استفاده میکنم، پروژه من با ترجمه ۱۰۰٪ کار میکند

پاسخ شماره ۱

من یک راهحل جایگزین برای آن پیدا کردم.

لازم نیست شیء فرهنگ لغت خود را صادر کنید، فقط کلیدها را به مقادیر ثابت تغییر دهید.

این برای من جواب داد:

// all translations
const dictionary = {
  "en": LANG_EN_TRANS,
  "ar": LANG_AR_TRANS,
  "fr": LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS = [
  { provide: TRANSLATIONS, useValue: dictionary },
];

پاسخ شماره ۲

بله، دقیقاً همانطور که @welefish در پاسخ خود گفته است، نیازی به صادر کردن شیء فرهنگ لغت خود ندارید، فقط باید کلیدها را به مقدار ثابت تغییر دهید.

پینوشت: - یک روش دیگر (به عنوان پاسخ ارسال میکنم چون روش @welefish برای من کار نمیکند)

let en = LANG_EN_NAME;
let er = LANG_AR_NAME;
let fr = LANG_FR_NAME;

const dictionary : any = {
    en: LANG_EN_TRANS,
    er: LANG_AR_TRANS,
    fr: LANG_FR_TRANS
};

// providers
export const TRANSLATION_PROVIDERS = [
  { provide: TRANSLATIONS, useValue: dictionary },
];