Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Do something about locale translation modules #2

Open
butterflyhug opened this issue Jul 21, 2014 · 4 comments
Open

Do something about locale translation modules #2

butterflyhug opened this issue Jul 21, 2014 · 4 comments

Comments

@butterflyhug
Copy link

Not sure how this should work. Current idea:

  • A global setting is used to write a locale selection into every FrozenMoment as it is created. Changing the global locale doesn't change the locale for existing objects.
  • Object-specific locales can only be changed by thawing and re-freezing the object -- that is, an object's locale state is immutable just like everything else.
  • All FrozenMoment methods that use the locale accept a locale key (e.g. "en-gb") as an optional method parameter that overrides the locale setting for just that call.

I think this proposal feels nicely consistent with the rest of the immutable API, but I'm not sure how it'll feel in use, and we at WhoopInc aren't currently using moment localization so I won't quickly gain much experience to drive my instincts on this issue.

@butterflyhug
Copy link
Author

See also @icambron's moment#1761, which proposes an upstream refactoring of moment's locale system. We should probably pull those changes when they're finalized.

@butterflyhug
Copy link
Author

See also @suprememoocow's moment#1621, which adds the ability to configure the language as part of the format method instead of changing it globally.

@suprememoocow
Copy link

Hi folks. I've just discovered your fork of Moment via the mention. I love the idea of this fork. Immutable value types lead to far fewer bugs - especially with dates. I've used Joda Time for years (a Java date library with immutable types) and believe it makes much more resilient code.

How far along is this project? Are you using it in production? I'm keen to move Gitter across to frozen moment once it's stable.

@butterflyhug
Copy link
Author

Awesome! Glad to have you here, @suprememoocow! Do you have any thoughts about the expected behavior of setting frozenMoment.lang() and instance.lang(), given the rest of our API changes?

I've got a proposal at the top of this issue, but I'm not sure whether it's the best way to go. I'm hoping to get some feedback from future users before I fix the localization system, especially since we aren't using any of the language translation modules in Whoop's (beta-quality) production app yet.

Project status report: We just started developing this fork last weekend, so it's still early days here. (PRs are more than welcome, if you want to get involved!) Our copy of the docs should be up to date with the current state of our code. FrozenMoment instances are actually immutable (unless you mess with their private properties yourself, of course), and all core Moment functionality except *.lang() and instance.zone() has worked perfectly in our testing and usage so far. We do still need to convert the moment.duration API and take a look at the performance / code quality impacts of our changes. I'm personally hoping we can get this in a state where we're comfortable migrating Whoop's app sometime in the next week or two.

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

No branches or pull requests

2 participants