Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using in project #11

Closed
samvloeberghs opened this issue Jan 8, 2016 · 10 comments
Closed

using in project #11

samvloeberghs opened this issue Jan 8, 2016 · 10 comments

Comments

@samvloeberghs
Copy link

Hi,

I'm trying to integrate this library in the starter kit provided by AngularClass:
https://github.com/AngularClass/angular2-webpack-starter.

PatrickJS/PatrickJS-starter#208

The webpack dev server is serving from the src folder. The translations are defined in
src/assets/i18n.

It doesn't seem to find the translation files using the provided setup:

export class App {
  name = 'Angular 2 Webpack Starter';
  url = 'https://twitter.com/AngularClass';
  constructor(translate: TranslateService) {

    var prefix = 'assets/i18n';
    var suffix = '.json';
    translate.useStaticFilesLoader(prefix, suffix);

    var userLang = navigator.language.split('-')[0]; // use navigator lang if available
    userLang = /(nl|fr|en)/gi.test(userLang) ? userLang : 'en';

    // optional, default is "en"
    translate.setDefaultLang('en');

    // the lang to use, if the lang isn't available, it will use the current loader to get them
    translate.use(userLang);

  }
}

But if I change the configuration to be var prefix = 'src/assets/i18n'; it works.

I'm not sure this is something related to your package or perhaps to the starter kit architecture. So that's why I'll post it and reference it in both projects.

Kr
Sam V.

@ocombe
Copy link
Collaborator

ocombe commented Jan 8, 2016

Yes, it's related to the starter architecture, not ng2-translate.
If you want to see my integration of the lib with webpack, check out my starter: https://github.com/ocombe/ng2-webpack

The problem in the case of AngularClass/angular2-webpack-starter is that the assets are not copied to your public repository/dev server.

You need to add 2 things to your webpack config:

@samvloeberghs
Copy link
Author

whoot, thx for the superspeedy reply! 👍 I'll get to it

@samvloeberghs
Copy link
Author

works like a charm!

@ocombe
Copy link
Collaborator

ocombe commented Jan 8, 2016

Perfect then :-)

@samvloeberghs
Copy link
Author

I'm adding it as an extension to the starterkit now :)

@ocombe
Copy link
Collaborator

ocombe commented Jan 8, 2016

\o/

Don't get too much into ng2-translate, the i18n official library by google for angular 2 looks very promising and they should do it before angular 2 release

@samvloeberghs
Copy link
Author

Learning too much too quick today, thx for headsup

@samvloeberghs
Copy link
Author

@ocombe ,are you still in favor of waiting for the official i18n or do you feel things have changed?

@ocombe
Copy link
Collaborator

ocombe commented Mar 1, 2016

Well I don't see anything moving on the i18n side, we might have to wait a few months until they release something...
As soon as I have more news I'll let you know, but if you need i18n right now you should use ng2-translate because you won't be able to use angular-i18n for at least 2 months (based on the idea that they would start working on it right now, which isn't the case).
As I'm learning new things with angular 2 I will keep ng2-translate updated and add a few new features because this lib helps me as well (I use it on my projects).
And if it appears that angular-i18n is too complex for simple use cases, then ng2-translate will not be deprecated and will live as a simpler alternative.

@samvloeberghs
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants