Coder Social home page Coder Social logo

How to handle import TranslateModule.forChild in module when creating a standalone component in an NgModule Application about core HOT 10 OPEN

chidav77 avatar chidav77 commented on June 16, 2024 2
How to handle import TranslateModule.forChild in module when creating a standalone component in an NgModule Application

from core.

Comments (10)

8th-block avatar 8th-block commented on June 16, 2024 1

@8th-block this one? https://angular.dev/guide/i18n

Yes

from core.

zazics avatar zazics commented on June 16, 2024

Hi,
I have almost same problem. For your translate pipe error, you have to import TranslateModule in your standalone component. But, then another problem appears. Translation are not loaded for your standalone component. Did you resolve this ?

from core.

chidav77 avatar chidav77 commented on June 16, 2024

No...unfortunately no one answered.
I would like to introduce gradually the standalone component, but This situation prevents me from doing so.

from core.

8th-block avatar 8th-block commented on June 16, 2024

I think this project went silent time to look for alternatives

from core.

zazics avatar zazics commented on June 16, 2024

@pretext-mats which alternatives do you recommend ?

from core.

8th-block avatar 8th-block commented on June 16, 2024

@pretext-mats which alternatives do you recommend ?

I have not got a faintest idea :-) Been using this translate since pre ng 2 ... may be I should not be looking for an alternative quite yet. For the SACs you can still load translation files manually if you want

from core.

cuddlecake avatar cuddlecake commented on June 16, 2024

I don't know the contents of your SharedModule, but if you're missing the translate pipe in your PricingComponent, then you need to add an import for TranslateModule, e.g.

@Component({
  selector: 'app-pricing',
  standalone: true,
  imports: [SharedModule, TranslateModule /* added import */],
  
  templateUrl: './pricing.component.html',
  styleUrls: ['./pricing.component.scss']
})
export class PricingComponent { }

The TranslateModule consists of component / pipe / directive exports in addition to the providers.
Before migrating your component to standalone, you might have declared the component in the same module where TranslateModule.forChild() had also been imported, and therefore the pipe was also available to the component.

from core.

8th-block avatar 8th-block commented on June 16, 2024

I don't know the contents of your SharedModule, but if you're missing the translate pipe in your PricingComponent, then you need to add an import for TranslateModule, e.g.

@Component({
  selector: 'app-pricing',
  standalone: true,
  imports: [SharedModule, TranslateModule /* added import */],
  
  templateUrl: './pricing.component.html',
  styleUrls: ['./pricing.component.scss']
})
export class PricingComponent { }

The TranslateModule consists of component / pipe / directive exports in addition to the providers. Before migrating your component to standalone, you might have declared the component in the same module where TranslateModule.forChild() had also been imported, and therefore the pipe was also available to the component.

Trust me it is not the case. We have tried that already still no joy - many other issues pop up

from core.

8th-block avatar 8th-block commented on June 16, 2024

I just switched to angular provided i18n module in the end ...

from core.

Fiehra avatar Fiehra commented on June 16, 2024

@8th-block this one?
https://angular.dev/guide/i18n

from core.

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.