Ron
Ron

Reputation: 593

angular2 after upgrade Error encountered resolving symbol values statically

i had upgraded to the latest angular cli and now i get this error:

Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'dictionary'. Consider exporting the symbol (position 12:7 in the original .ts file), resolving symbol TRANSLATION_PROVIDERS in C:/xampp/htdocs/milesofmusic/src/app/translate/translation.ts, resolving symbol AppModule in C:/xampp/htdocs/milesofmusic/src/app/app.module.ts, resolving symbol AppModule in C:/xampp/htdocs/milesofmusic/src/app/app.module.ts

the code it refers to is this:

// all traslations
const dictionary = {
    [LANG_EN_NAME]: LANG_EN_TRANS,
    [LANG_HE_NAME]: LANG_HE_TRANS,
};

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

and in my app module i import import { TRANSLATION_PROVIDERS } from './translate/translation'; and have it in the providers array

how to fix it?

Upvotes: 3

Views: 1124

Answers (2)

Rasal Shukla
Rasal Shukla

Reputation: 11

const dictionary  = {
    [LANG_EN_NAME]: LANG_EN_TRANS,
    [LANG_FR_NAME]: LANG_FR_TRANS,

};

I am also getting the same error, so do one thing: directly write the language value instead of the brackets.

const dictionary  = {
    "en-US": LANG_EN_TRANS,
    "fr-FR": LANG_FR_TRANS,
};

Enjoy Happy Coding

Upvotes: 1

Poul Kruijt
Poul Kruijt

Reputation: 71961

I believe you got this example from an old guide somewhere on the world wide web. As far as I remember, this one is outdated and it's not the appropriate way anymore to handle translations within angular2. I suggest you take a look at the i18n internationalization cookbook of angular.

Upvotes: 0

Related Questions