Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/tests/ export-ignore
/.* export-ignore
/gh-pages/ export-ignore
/tests/ export-ignore
/README.md export-ignore
/phpunit.xml export-ignore
52 changes: 52 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build GitHub Pages

on:
push:
branches:
- main
tags-ignore:
- "**"
workflow_dispatch:
inputs:
recreate-json:
description: 'Re-create JSON files'
type: boolean

permissions:
contents: write
pages: write
id-token: write

jobs:
publish:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Delete existing JSON files
if: github.event.inputs.recreate-json
run: rm -rf gh-pages/public/data/versions
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: gh-pages/package-lock.json
- name: Install dependencies
working-directory: gh-pages
run: npm ci
- name: Check coding style
working-directory: gh-pages
run: npm run lint:check
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: gh-pages/dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- main
tags-ignore:
- "**"
paths-ignore:
- .github/workflows/gh-pages.yml
- "gh-pages/**"
pull_request:
branches:
- main
Expand Down
26 changes: 26 additions & 0 deletions gh-pages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/dist/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions gh-pages/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/public/
15 changes: 15 additions & 0 deletions gh-pages/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://prettier.io/docs/options
printWidth: 80
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
quoteProps: as-needed
jsxSingleQuote: false
trailingComma: all
bracketSpacing: false
bracketSameLine: false
arrowParens: always
vueIndentScriptAndStyle: false
endOfLine: lf
singleAttributePerLine: false
3 changes: 3 additions & 0 deletions gh-pages/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "esbenp.prettier-vscode"]
}
8 changes: 8 additions & 0 deletions gh-pages/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
43 changes: 43 additions & 0 deletions gh-pages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Development

### Install dependencies (keeping the configured one)

```sh
npm ci
```

### Install dependencies (updating to the latest available versions)

```sh
npm install
```

### Build for development

```sh
npm run dev
```

### Checking coding style

```sh
npm run lint:check
```

### Fixing coding style

```sh
npm run lint:fix
```

### Build for production

```sh
npm run build
```

### Preview the app built for production

```sh
npm run preview
```
88 changes: 88 additions & 0 deletions gh-pages/bin/create-cldr-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import child_process from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

const PROJECT_ROOT = path
.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
.replaceAll(path.sep, '/')
.replace(/\/$/, '');

const DATADIR =
path
.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
.replaceAll(path.sep, '/')
.replace(/\/$/, '') + '/public/data';

const VERSIONS = JSON.parse(fs.readFileSync(`${DATADIR}/versions.json`));
if (!fs.existsSync(`${DATADIR}/versions`)) {
fs.mkdirSync(`${DATADIR}/versions`);
}

for (let version of VERSIONS) {
const outputFileCompressed = `${DATADIR}/versions/${version}.min.json`;
const outputFileUncompressed = `${DATADIR}/versions/${version}.json`;
if (
fs.existsSync(outputFileCompressed) &&
fs.existsSync(outputFileUncompressed)
) {
continue;
}
process.stdout.write(`# Creating data for version ${version}\n`);
const importer = child_process.spawn(
'php',
[`${PROJECT_ROOT}/bin/import-cldr-data`, version],
{
stdio: [
// stdin
'ignore',
// stout
'inherit',
// stderr
'inherit',
],
},
);
await new Promise((resolve, reject) => {
importer.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Child process exited with code ${code}`));
}
});
});
process.stdout.write('Creating json files\n');
for (let compressed of [false, true]) {
const outputFile = compressed
? outputFileCompressed
: outputFileUncompressed;
const exporter = child_process.spawn(
'php',
[
`${PROJECT_ROOT}/bin/export-plural-rules`,
`--output=${outputFile}`,
compressed ? 'json' : 'prettyjson',
],
{
stdio: [
// stdin
'ignore',
// stout
'inherit',
// stderr
'inherit',
],
},
);
await new Promise((resolve, reject) => {
exporter.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Child process exited with code ${code}`));
}
});
});
}
}
26 changes: 26 additions & 0 deletions gh-pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
(function () {
const url = new URL(window.location.href);
if (!/(\/|\.html?)$/i.test(url.pathname)) {
url.pathname += '/';
window.history.replaceState(null, '', url.href);
}
})();
</script>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="List of all language rules for gettext .po files automatically generated from the Unicode CLDR data"
/>
<title>gettext plural rules - built from CLDR</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
Loading