Code Monkey home page Code Monkey logo

Comments (5)

robisim74 avatar robisim74 commented on June 6, 2024 1

Hi Matthias,

  1. Yes: because pipes are pure you have to extend Locale class that provides the values for lang and defaultLocale parameters. It's normal to use inheritance in OOP, and it isn't a pollution.
    Alternatively, you can use Html attributes: https://github.com/robisim74/angular2localization/blob/master/doc/spec.md#2.4 (and you can use the pipes only when you can not use Html attributes, as with the placeholders etc.)
    To know why this project is passed to the pure pipes, see this post: #33

  2. I don't know a way to use only {{ 'foo' | translate }} using pure pipes: I tried in every way, without success.
    About TSLint/Codelyzer, I have already opened this issue: mgechev/codelyzer#191

The value of lang is already optional (not the parameter), and the default language is already used: but without it, and without extending the Locale class:

  • you have to use Advanced initialization to make sure the app is rendered after the http request of the json files is completed
  • you can't change language at runtime (you need a new bootstrap of the application)

Greetings,

Roberto

from angular-l10n.

mscudlik avatar mscudlik commented on June 6, 2024

Hi Roberto,

thanks a lot for explaing things helping me out :)

  1. i know that inheriting is not a pollution in general, but i think it kind of restricts me from having my own super class and it is "a lot" of boilerplate code (if you have to do it in a lot of components). So thanks a lot for the hint with the HTML attributes, i think i'll go this way whereever i can. One thing that came up when i experimented with the HTML attributes:

i had to use

<div translate>foo</div>

and this didn't work:

<div translate>
    foo
</div>

Probably because of the spaces - if there is no reason to keep it this way you might consider to trim the white spaces :)

  1. I'm not an expert creating own pipes and not sure why you used impure before, but since you already have the services available in the pipe - why not just use the value from the service?

Can you provide an example with Advanced Initialization or is this what you mean with it? I'd rather not "code" the translation, on the other hand i could just use seperate .ts files instead of json for that

Thanks and best regards,
Matthias

from angular-l10n.

mscudlik avatar mscudlik commented on June 6, 2024

Just saw #33, sorry :-)

from angular-l10n.

robisim74 avatar robisim74 commented on June 6, 2024

No problem.

  1. About the Html attributes, I'll evaluate to trim the white spaces in the next release. Thanks for the tip!

  2. We can't use the value from the service because the transform method of a pure pipe is invoked by Angular Change Detection mechanism only when the input parameters change.

Greetings,

Roberto

from angular-l10n.

robisim74 avatar robisim74 commented on June 6, 2024

I'm closing it. If you need, open a new issue. Greetings

from angular-l10n.

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.