Skip to content

Commit f85153d

Browse files
authored
Merge pull request #959 from nextcloud-libraries/fix-l10n
Fix l10n
2 parents b8c9254 + 4e978a1 commit f85153d

8 files changed

Lines changed: 258 additions & 69 deletions

File tree

.github/workflows/documentation.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ jobs:
2323
name: Build and deploy
2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2727
with:
2828
persist-credentials: false
2929

30+
- name: Read package.json
31+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
32+
id: versions
33+
3034
- name: Set up node
31-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
35+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3236
with:
33-
node-version-file: 'package.json'
37+
node-version: ${{ steps.versions.outputs.node-version }}
38+
39+
- name: Set up npm
40+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
3441

3542
- name: Install dependencies & build
3643
env:

.github/workflows/lint-eslint.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@ jobs:
2525

2626
steps:
2727
- name: Checkout
28-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2929
with:
3030
persist-credentials: false
3131

32+
- name: Read package.json
33+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
34+
id: versions
35+
3236
- name: Set up node
33-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
37+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3438
with:
35-
node-version-file: 'package.json'
39+
node-version: ${{ steps.versions.outputs.node-version }}
40+
41+
- name: Set up npm
42+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
3643

3744
- name: Install dependencies
3845
env:

.github/workflows/node-test.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,21 @@ jobs:
3030

3131
steps:
3232
- name: Checkout
33-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3434
with:
3535
persist-credentials: false
3636

37+
- name: Read package.json
38+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
39+
id: versions
40+
3741
- name: Set up node
38-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
42+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3943
with:
40-
node-version-file: 'package.json'
44+
node-version: ${{ steps.versions.outputs.node-version }}
45+
46+
- name: Set up npm
47+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
4148

4249
- name: Install dependencies & build
4350
env:
@@ -53,6 +60,8 @@ jobs:
5360
run: npm run test:coverage --if-present
5461

5562
- name: Collect coverage
56-
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
63+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
5764
with:
5865
files: ./coverage/lcov.info
66+
env:
67+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/node.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ jobs:
2424

2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2828
with:
2929
persist-credentials: false
3030

31+
- name: Read package.json
32+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
33+
id: versions
34+
3135
- name: Set up node
32-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
36+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3337
with:
34-
node-version-file: 'package.json'
38+
node-version: ${{ steps.versions.outputs.node-version }}
39+
40+
- name: Set up npm
41+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
3542

3643
- name: Install dependencies & build
3744
env:

.github/workflows/npm-publish.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ jobs:
2323

2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2727
with:
2828
persist-credentials: false
2929

30+
- name: Read package.json
31+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
32+
id: versions
33+
3034
- name: Set up node
31-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
35+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3236
with:
33-
node-version-file: 'package.json'
37+
node-version: ${{ steps.versions.outputs.node-version }}
38+
39+
- name: Set up npm
40+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
3441

3542
- name: Check tag matches package.json
3643
run: |

.github/workflows/reuse.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2323
with:
2424
persist-credentials: false
2525

2626
- name: REUSE Compliance Check
27-
uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5.0.0
27+
uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 # v6.0.0

lib/date.ts

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,36 @@ export function getDayNames(): string[] {
5454
// Fallback to Intl
5555
const locale = getCanonicalLocale()
5656
return [
57-
new Date('1970-01-04T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
58-
new Date('1970-01-05T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
59-
new Date('1970-01-06T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
60-
new Date('1970-01-07T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
61-
new Date('1970-01-08T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
62-
new Date('1970-01-09T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
63-
new Date('1970-01-10T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'long' }),
57+
new Date(1970, 0, 4).toLocaleDateString(locale, { weekday: 'long' }),
58+
new Date(1970, 0, 5).toLocaleDateString(locale, { weekday: 'long' }),
59+
new Date(1970, 0, 6).toLocaleDateString(locale, { weekday: 'long' }),
60+
new Date(1970, 0, 7).toLocaleDateString(locale, { weekday: 'long' }),
61+
new Date(1970, 0, 8).toLocaleDateString(locale, { weekday: 'long' }),
62+
new Date(1970, 0, 9).toLocaleDateString(locale, { weekday: 'long' }),
63+
new Date(1970, 0, 10).toLocaleDateString(locale, { weekday: 'long' }),
6464
]
6565
}
6666

6767
/**
6868
* Get a list of day names (short names)
6969
*/
7070
export function getDayNamesShort(): string[] {
71+
// Server rendered
7172
if (typeof globalThis.dayNamesShort !== 'undefined') {
7273
return globalThis.dayNamesShort
7374
}
7475

7576
// Fallback to Intl
76-
// Note: narrow is shorter than server's "min", but it's the closest we can get
77+
// Note: short is shorter than server's "short", but it's the closest we can get
7778
const locale = getCanonicalLocale()
7879
return [
79-
new Date('1970-01-04T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
80-
new Date('1970-01-05T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
81-
new Date('1970-01-06T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
82-
new Date('1970-01-07T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
83-
new Date('1970-01-08T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
84-
new Date('1970-01-09T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
85-
new Date('1970-01-10T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'short' }),
80+
new Date(1970, 0, 4).toLocaleDateString(locale, { weekday: 'short' }),
81+
new Date(1970, 0, 5).toLocaleDateString(locale, { weekday: 'short' }),
82+
new Date(1970, 0, 6).toLocaleDateString(locale, { weekday: 'short' }),
83+
new Date(1970, 0, 7).toLocaleDateString(locale, { weekday: 'short' }),
84+
new Date(1970, 0, 8).toLocaleDateString(locale, { weekday: 'short' }),
85+
new Date(1970, 0, 9).toLocaleDateString(locale, { weekday: 'short' }),
86+
new Date(1970, 0, 10).toLocaleDateString(locale, { weekday: 'short' }),
8687
]
8788
}
8889

@@ -96,15 +97,16 @@ export function getDayNamesMin(): string[] {
9697
}
9798

9899
// Fallback to Intl
100+
// Note: narrow is shorter than server's "min", but it's the closest we can get
99101
const locale = getCanonicalLocale()
100102
return [
101-
new Date('1970-01-04T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
102-
new Date('1970-01-05T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
103-
new Date('1970-01-06T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
104-
new Date('1970-01-07T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
105-
new Date('1970-01-08T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
106-
new Date('1970-01-09T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
107-
new Date('1970-01-10T00:00:00.000Z').toLocaleDateString(locale, { weekday: 'narrow' }),
103+
new Date(1970, 0, 4).toLocaleDateString(locale, { weekday: 'narrow' }),
104+
new Date(1970, 0, 5).toLocaleDateString(locale, { weekday: 'narrow' }),
105+
new Date(1970, 0, 6).toLocaleDateString(locale, { weekday: 'narrow' }),
106+
new Date(1970, 0, 7).toLocaleDateString(locale, { weekday: 'narrow' }),
107+
new Date(1970, 0, 8).toLocaleDateString(locale, { weekday: 'narrow' }),
108+
new Date(1970, 0, 9).toLocaleDateString(locale, { weekday: 'narrow' }),
109+
new Date(1970, 0, 10).toLocaleDateString(locale, { weekday: 'narrow' }),
108110
]
109111
}
110112

@@ -120,18 +122,18 @@ export function getMonthNames(): string[] {
120122
// Fallback to Intl
121123
const locale = getCanonicalLocale()
122124
return [
123-
new Date('1970-01-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
124-
new Date('1970-02-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
125-
new Date('1970-03-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
126-
new Date('1970-04-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
127-
new Date('1970-05-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
128-
new Date('1970-06-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
129-
new Date('1970-07-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
130-
new Date('1970-08-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
131-
new Date('1970-09-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
132-
new Date('1970-10-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
133-
new Date('1970-11-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
134-
new Date('1970-12-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'long' }),
125+
new Date(1970, 0).toLocaleDateString(locale, { month: 'long' }),
126+
new Date(1970, 1).toLocaleDateString(locale, { month: 'long' }),
127+
new Date(1970, 2).toLocaleDateString(locale, { month: 'long' }),
128+
new Date(1970, 3).toLocaleDateString(locale, { month: 'long' }),
129+
new Date(1970, 4).toLocaleDateString(locale, { month: 'long' }),
130+
new Date(1970, 5).toLocaleDateString(locale, { month: 'long' }),
131+
new Date(1970, 6).toLocaleDateString(locale, { month: 'long' }),
132+
new Date(1970, 7).toLocaleDateString(locale, { month: 'long' }),
133+
new Date(1970, 8).toLocaleDateString(locale, { month: 'long' }),
134+
new Date(1970, 9).toLocaleDateString(locale, { month: 'long' }),
135+
new Date(1970, 10).toLocaleDateString(locale, { month: 'long' }),
136+
new Date(1970, 11).toLocaleDateString(locale, { month: 'long' }),
135137
]
136138
}
137139

@@ -147,17 +149,17 @@ export function getMonthNamesShort(): string[] {
147149
// Fallback to Intl
148150
const locale = getCanonicalLocale()
149151
return [
150-
new Date('1970-01-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
151-
new Date('1970-02-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
152-
new Date('1970-03-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
153-
new Date('1970-04-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
154-
new Date('1970-05-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
155-
new Date('1970-06-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
156-
new Date('1970-07-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
157-
new Date('1970-08-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
158-
new Date('1970-09-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
159-
new Date('1970-10-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
160-
new Date('1970-11-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
161-
new Date('1970-12-01T00:00:00.000Z').toLocaleDateString(locale, { month: 'short' }),
152+
new Date(1970, 0).toLocaleDateString(locale, { month: 'short' }),
153+
new Date(1970, 1).toLocaleDateString(locale, { month: 'short' }),
154+
new Date(1970, 2).toLocaleDateString(locale, { month: 'short' }),
155+
new Date(1970, 3).toLocaleDateString(locale, { month: 'short' }),
156+
new Date(1970, 4).toLocaleDateString(locale, { month: 'short' }),
157+
new Date(1970, 5).toLocaleDateString(locale, { month: 'short' }),
158+
new Date(1970, 6).toLocaleDateString(locale, { month: 'short' }),
159+
new Date(1970, 7).toLocaleDateString(locale, { month: 'short' }),
160+
new Date(1970, 8).toLocaleDateString(locale, { month: 'short' }),
161+
new Date(1970, 9).toLocaleDateString(locale, { month: 'short' }),
162+
new Date(1970, 10).toLocaleDateString(locale, { month: 'short' }),
163+
new Date(1970, 11).toLocaleDateString(locale, { month: 'short' }),
162164
]
163165
}

0 commit comments

Comments
 (0)