Skip to content
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

Use POSIX locale identifier #749

Merged
merged 1 commit into from
May 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ function assertEqualCalendarMatrix(a: Date[][], b: Date[][]) {
}

const utc = Timezone.UTC;
const en_us = LOCALES.EN_US;
const en_us = LOCALES["en-US"];
const warsawTZ = Timezone.fromJS("Europe/Warsaw");

const getDateInTimezone = (day: string, timezone: Timezone) => getMomentWithTimezone(day, timezone.toString()).toDate();
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ describe("DateRangePicker", () => {
it("adds the correct class", () => {
var renderedComponent = renderIntoDocument(
<DateRangePicker
locale={LOCALES.EN_US}
locale={LOCALES["en-US"]}
startTime={new Date(Date.UTC(2003, 11, 2))}
endTime={new Date(Date.UTC(2004, 11, 2))}
maxTime={new Date(Date.UTC(2004, 11, 2))}
@@ -78,7 +78,7 @@ describe("DateRangePicker", () => {
expect(() => {
renderIntoDocument(
<DateRangePicker
locale={LOCALES.EN_US}
locale={LOCALES["en-US"]}
startTime={new Date(Date.UTC(2003, 11, 2))}
endTime={null}
maxTime={new Date(Date.UTC(2004, 11, 2))}
2 changes: 1 addition & 1 deletion src/client/components/filter-menu/filter-menu.mocha.tsx
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ class Wrap extends React.Component {
return <FilterMenu
clicker={null}
containerStage={null}
locale={LOCALES.EN_US}
locale={LOCALES["en-US"]}
dimension={DimensionFixtures.wikiCommentLength()}
essence={EssenceFixtures.wikiTotals()}
timekeeper={TimekeeperFixtures.fixed()}
2 changes: 1 addition & 1 deletion src/client/components/filter-tile/filter-tile.mocha.tsx
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ describe("FilterTile", () => {
essence={EssenceFixtures.wikiTotals()}
timekeeper={TimekeeperFixtures.fixed()}
menuStage={null}
locale={LOCALES.EN_US}/>
locale={LOCALES["en-US"]}/>
);

expect(TestUtils.isCompositeComponent(renderedComponent), "should be composite").to.equal(true);
4 changes: 2 additions & 2 deletions src/common/models/app-settings/app-settings.fixtures.ts
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ export const clientAppSettings: ClientAppSettings = {
hasUrlShortener: false,
externalViews: [],
timezones: [],
locale: LOCALES.EN_US
locale: LOCALES["en-US"]
},
oauth: { status: "disabled" },
clientTimeout: 1000
@@ -34,7 +34,7 @@ export const appSettings: AppSettings = {
clientTimeout: 1000,
customization: {
timezones: [],
locale: LOCALES.EN_US,
locale: LOCALES["en-US"],
externalViews: [],
cssVariables: {}
},
6 changes: 3 additions & 3 deletions src/common/models/locale/locale.mocha.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
import { expect } from "chai";
import { fromConfig, LOCALES } from "./locale";

const en_us = LOCALES.EN_US;
const en_us = LOCALES["en-US"];

describe("locale", () => {
describe("fromConfig", () => {
@@ -28,13 +28,13 @@ describe("locale", () => {
});

it("should use base locale", () => {
const locale = fromConfig({ base: "EN_US", overrides: {} });
const locale = fromConfig({ base: "en-US", overrides: {} });

expect(locale).to.deep.equal(en_us);
});

it("should use base locale and override desired fields", () => {
const locale = fromConfig({ base: "EN_US", overrides: { weekStart: 42 } });
const locale = fromConfig({ base: "en-US", overrides: { weekStart: 42 } });

expect(locale).to.deep.equal({
...en_us,
8 changes: 4 additions & 4 deletions src/common/models/locale/locale.ts
Original file line number Diff line number Diff line change
@@ -16,20 +16,20 @@

import { isObject } from "../../utils/general/general";

const EN_US: Locale = {
const enUS: Locale = {
shortDays: ["S", "M", "T", "W", "T", "F", "S"],
shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"],
weekStart: 0,
exportEncoding: "utf-8"
};

type LocaleName = "EN_US";
type LocaleName = "en-US";

export const LOCALES: Record<LocaleName, Locale> = {
EN_US
"en-US": enUS
};

const DEFAULT_LOCALE = EN_US;
const DEFAULT_LOCALE = enUS;

export interface LocaleJS {
base: LocaleName;