Comments (5)
The only bad thing was, that the function was internal changed/removed, which i haven't expected in an minor update.
Definitely. It's something that I, as an end-developer of some addon, would hate to experience as well.
Unfortunately, to remove ember-intl
's tech debts, I think v6.x
will have to make some changes that may be non-breaking for 80% of the consuming apps, and ask the other 20% to make adjustments on their end. Of course, we'll document how projects may migrate their code in release notes and issues like this.
At the moment, adding features isn't on the table, but I'll keep your suggestion in mind. I'd like to simplify code first so that we can introduce features in a good, sustainable way.
from ember-intl.
I'll close this issue, as it documented a couple of ways to migrate code.
from ember-intl.
Hi, @mkszepp. The issue that you described seems similar to #1813, where an end-developer overwrote a helper that ember-intl
provides, to change the helper's default behavior.
I think this is a brittle approach. Whether your helper works depends on ember-intl
's implementation details (e.g. the compute()
method used to call another method called format()
) and can prevent ember-intl
from changing the implementation for the better.
In your case, I think it'd be better to explicitly set the format
option in your template(s), as documented in https://ember-intl.github.io/ember-intl/versions/v6.1.0/docs/helpers/format-date#custom-format. Would this be another possibility? (That is, if there aren't many places where you called {{format-date}}
, I'd go ahead with adding the format
option.)
from ember-intl.
An alternative is to create a helper that extends the Helper
class from @ember/component/helper
and injects the intl
service.
import Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
import type { IntlService } from 'ember-intl';
export default class MyFormatDateHelper extends Helper {
@service declare intl: IntlService;
constructor() {
// eslint-disable-next-line prefer-rest-params
super(...arguments);
// @ts-expect-error: Property 'onLocaleChanged' is private and only accessible within class 'IntlService'.
this.intl.onLocaleChanged(this.recompute, this);
}
compute([date], options): string {
if (!options.format) {
return this.intl.formatDate(date, {
...options,
format: 'default',
});
}
return this.intl.formatDate(date, options);
}
}
I think this is still not an ideal solution, as implementation details are leaked in the constructor and the type for options
in compute()
.
from ember-intl.
Hi @ijlee2 ,
thank you for your response.
I don't like to work with code functions/properties that are intended only for internal/private uses, because there are not documented and could changed any time without any notification.
I think, my actual helper extending is the best way, because i don't like to set the format in every implementation manually, because the date format should equal in all cases.
The only bad thing was, that the function was internal changed/removed, which i havn't expected in an minor update.
A possible enhancement for the addon could be, that the service allows to pass default formats... what do you think about that? Is something like that possible?
from ember-intl.
Related Issues (20)
- Double `intl.d.ts` cause type errors HOT 8
- Unexpected locale `en-us` after upgrade to ember-intl v6 HOT 6
- A simple, autogenerated integration test fails for a component using a translation in ember-intl 6.1.2 HOT 6
- Bundle size regression in v6.2.0 HOT 3
- Merge this into formatjs HOT 3
- Incompatible with native `ember-source` types HOT 5
- `allowEmpty` class property not respected in v6.3.1 HOT 1
- Basic usage results in: You attempted to update `_locale` [...] infinite revalidation bugs, and performance issues, and is not supported. HOT 4
- How to use `publicOnly: true` in Embroider apps HOT 13
- v6 - Error on valid use of `many`: message cannot be parsed: Unknown plural category: many HOT 1
- Deleted
- Plans for v7 release
- Memory leak regression after upgrading to `>= 6.3.0` HOT 3
- Do not blow up the whole page if a variable is missing ? HOT 2
- Vulnerability in dependency `glob-parent` via `broccoli-merge-files` HOT 10
- Create a docs-app that checks `wrapTranslationsWithNamespace: true`
- Create a docs-app that checks fetching translations HOT 1
- Create a docs-app that checks `publicOnly: true`
- Could not find module `eventemitter3` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-intl.