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

Allow specifying locale for Date converter #3820

Merged
merged 4 commits into from May 16, 2017

Conversation

Projects
None yet
2 participants
@joschi
Contributor

joschi commented May 12, 2017

Description

The Date converter was using the system locale for parsing date strings, which can lead to unwanted results in environments with multiple languages (e. g. month names) or "unclean" runtime environments.

This PR adds an attribute to the Date converter which specifies the locale being used for parsing strings.

Closes #3811

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

joschi added some commits May 11, 2017

@joschi joschi added this to the 2.3.0 milestone May 12, 2017

@kroepke kroepke self-requested a review May 16, 2017

@kroepke

Other than the undefined entry, lgtm!

@JsonProperty("locales")
public abstract ImmutableMap<String, LocaleDescription> locales();
public static LocalesResponse create(Locale[] locales) {

This comment has been minimized.

@kroepke

kroepke May 16, 2017

Member

Locally I get the following entry (via Locale.getAvailableLocales()) among the expected ones:

"und": {
  "language_tag": "und",
  "display_name": ""
},

We should probably filter these out, not sure where they come from but they seem useless for the user.
According to JDK docs these seem to be representable in BCP 47.

This comment has been minimized.

@joschi

joschi May 16, 2017

Contributor

und is required for the Locale#forLanguageTag(String) method and describes the "POSIX" locale (i. e. the same as locale "C").

This being said, we could probably use another display name in the web interface for it.

This comment has been minimized.

@kroepke

kroepke May 16, 2017

Member

Ah! I was wondering what it was. Yeah, then we should probably special case that one, it's hard to understand otherwise.
Thanks for the explanation :)

@kroepke kroepke merged commit b164feb into master May 16, 2017

4 checks passed

ci-web-linter Jenkins build graylog-pr-linter-check 1646 has succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
graylog-project/pr Jenkins build graylog-project-pr-snapshot 124 has succeeded
Details

@kroepke kroepke deleted the issue-3811 branch May 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment