-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make pluralSpecs non-global #82
Milestone
Comments
I agree that global state is not ideal and regret having a global default bundle as well. |
bep
added a commit
to bep/go-i18n
that referenced
this issue
Nov 5, 2017
This is a follow up to this long-lived Hugo issue: gohugoio/hugo#3564 This may be improved on in nicksnyder#82 -- but this one is needed just go get it done. The plan for Hugo's part is: For all the language codes in use: 1. Check if it is already registered (`GetPluralSpec`) 2. If not, register it as an alias to `GetPluralSpec("en")`
Merged
nicksnyder
pushed a commit
that referenced
this issue
Nov 5, 2017
This is a follow up to this long-lived Hugo issue: gohugoio/hugo#3564 This may be improved on in #82 -- but this one is needed just go get it done. The plan for Hugo's part is: For all the language codes in use: 1. Check if it is already registered (`GetPluralSpec`) 2. If not, register it as an alias to `GetPluralSpec("en")`
V2 contains a proposal to solve this. Please review #92 |
I just tagged 2.0.0.beta.1. Please start using it and report any issues that you have. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This replaces the rejected #81
While @nicksnyder is right about thread safety being the client's responsibility, the global
pluralSpecs
makes it harder than it should.And then having
RegisterPluralSpec
mutate that state.In Hugo we run most tests with
t.Parallel()
. And while this may report some data races we may not realistically see in real use scenarios, it is well worth it.In this case, it reports a data race in
pluralSpecs
when using theRegisterPluralSpec
. We can probably fix that by adding some global locks.But these globals also has another unfortunate side-effect:
We cannot run multiple
go-i18n
configurations side-by-side. And this has nothing to do with concurrency.So, it would be much better if you could provide a constructor func that takes the options needed (plural specs etc.)
The text was updated successfully, but these errors were encountered: