Git Product home page Git Product logo

Comments (10)

Romanchuk avatar Romanchuk commented on May 27, 2024 1

@ceelian Sure, thx, fixed

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024 1

@Antarus66 Hello, it looks like you are trying to import wrong path.

import { I18NextPipe } from 'angular-i18next'; // not from 'angular-i18next/I18NextPipe'

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024

@aysedilekk Hi, what version? 5.0.0-beta3?

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024

@aysedilekk since v.5 package bundle would satisfy Angular Package Format (APF) v6.0
https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview#heading=h.k0mh3o8u5hx
Paths would be changed

from angular-i18next.

aysedilekk avatar aysedilekk commented on May 27, 2024

@aysedilekk Hi, what version? 5.0.0-beta3?

Thanks @Romanchuk,
My angular version 5.2.0 and I solved this problem with different package version ([email protected] [email protected]).

from angular-i18next.

Romanchuk avatar Romanchuk commented on May 27, 2024

@aysedilekk why do you need to attach angular-i18next via scripts in angular.json?
Installation can be done without it.

angular-cli.json,

"scripts": [
"../node_modules/angular-i18next/es5/angular-i18next.js"
]

from angular-i18next.

aysedilekk avatar aysedilekk commented on May 27, 2024

@Romanchuk Yes, you're right. I removed this part from angular.json. It is done.

@aysedilekk why do you need to attach angular-i18next via scripts in angular.json?
Installation can be done without it.

angular-cli.json,
"scripts": [
"../node_modules/angular-i18next/es5/angular-i18next.js"
]

from angular-i18next.

ceelian avatar ceelian commented on May 27, 2024

Similar problem with Angular 7.0

ERROR in /Users/ceelian/devel/example-project/node_modules/angular-i18next/fesm5/angular-i18next.js Module not found: Error: Can't resolve 'i18next/index' in '/Users/ceelian/devel/example-project/node_modules/angular-i18next/fesm5'

angular-i18next v5.0.6

from angular-i18next.

ceelian avatar ceelian commented on May 27, 2024

The problem was, that i18next was not installed (thought that it is a dependency of angular-i18next but just a peer dependency). It my be a good idea to also add this info to the installation docs as well, that

npm install i18next --save

is needed.

from angular-i18next.

Antarus66 avatar Antarus66 commented on May 27, 2024

Hi there! Thanks for this nice lib!

Regretfully, I have the same issue.

ERROR in ./src/app/base/components/password-reset/password-reset.component.ts
Module not found: Error: Can't resolve 'angular-i18next/I18NextPipe' in '/Users/Andrii/Code/nextree/nxt-profile/src/app/base/components/password-reset'

package.json

"@angular/core": "~8.2.14",
...
"i18next": "^19.3.4",
"angular-i18next": "^7.0.0",

i18n-providers.ts

import { APP_INITIALIZER, LOCALE_ID } from '@angular/core';
import { I18NEXT_SERVICE, I18NextTitle, ITranslationService } from 'angular-i18next';
import { Language } from '../enums/language.enum';
import { environment } from '../../../environments/environment';
import { Namespace } from '../enums/namespace.enum';
import { Title } from '@angular/platform-browser';
import { LANGUAGE_SAVER, LanguageSaver } from './language-saver/language-saver';
import { LocalStorageLanguageSaver } from './language-saver/local-storage-language-saver';
import { resourcesIndex } from './resources-index';
import { skip } from 'rxjs/operators';

function subscribeToLanguageChange(
  i18NextService: ITranslationService,
  initialLanguageSaver: LanguageSaver
): void {
  i18NextService.events.languageChanged
    .pipe(
      skip(1)
    )
    .subscribe((newLanguage: string) => {
      initialLanguageSaver.set(newLanguage as Language);
      window.location.reload();
    });
}

function appInit(
  i18NextService: ITranslationService,
  initialLanguageSaver: LanguageSaver
): Function {
  return (): Promise<any> => {
    const initResult = i18NextService.init({
      lng: initialLanguageSaver.get() || Language.EN,
      whitelist: [
        Language.EN,
        Language.DE,
        Language.FR,
        Language.IT,
      ],
      nonExplicitWhitelist: true,
      cleanCode: true,
      fallbackLng: Language.EN,
      debug: !environment.isProduction,
      returnEmptyString: false,
      ns: [Namespace.PasswordReset],
      resources: resourcesIndex
    });

    subscribeToLanguageChange(i18NextService, initialLanguageSaver);

    return initResult;
  };
}

function localeIdFactory(i18next: ITranslationService): string  {
  return i18next.language;
}

export const I18N_PROVIDERS = [
  {
    provide: APP_INITIALIZER,
    useFactory: appInit,
    deps: [I18NEXT_SERVICE, LANGUAGE_SAVER],
    multi: true
  },
  {
    provide: LOCALE_ID,
    deps: [I18NEXT_SERVICE],
    useFactory: localeIdFactory
  },
  {
    provide: LANGUAGE_SAVER,
    useClass: LocalStorageLanguageSaver
  },
  {
    provide: Title,
    useClass: I18NextTitle
  }
];

Could you please take a look what might be a reason of this issue?
Thank you!

from angular-i18next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.