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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This file orients AI tools to the flightctl-ui repo layout and conventions. The
## Generated files – do not edit by hand

- **Models / API types** (`libs/types`): Generated from the flightctl OpenAPI schema. Regenerate with **`npm run gen-types`** (from repo root). Agents must not modify or suggest changes to these generated files; changes are driven entirely from the OpenAPI spec in the flightctl repo.
- **Translations** (`libs/i18n/locales/en/translation.json`): Generated by scanning source for i18n keys. Agents must not edit `translation.json` manually; they should add or fix keys in the source and run the **`npm run i18n`** command (from repo root). Translation expressions can include variables, but the text itself must be hardcoded for the extraction to work. **Good:** `t('This is OK', { someVar })` — **Bad:** `t(usingAVariableIsNotOk)` (key not extractable).
- **Translations** (`libs/i18n/locales/en/translation.json`): Generated by scanning source for i18n keys with i18next-cli. Agents must not edit `translation.json` manually; they should add or fix keys in the source and run **`npm run i18n`** (from repo root) to regenerate it. **`npm run i18n:check`** verifies that the catalog is up to date without writing changes. Translation expressions can include variables, but the text itself must be hardcoded for the extraction to work. **Good:** `t('This is OK', { someVar })` — **Bad:** `t(usingAVariableIsNotOk)` (key not extractable).

## UI architecture

Expand Down
8 changes: 4 additions & 4 deletions UI-ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ constraints:
double braces, not JSX expressions.
- **Components take translated strings**, never i18n keys. The caller runs
`t()` and passes the result: `<ListPage title={t('Fleets')}>`.
- **Keys are flat** — `keySeparator: false` in the parser config. No dot
- **Keys are flat** — `keySeparator: false` in the i18next-cli config. No dot
notation nesting.
- **Colons in translation text** require `nsSeparator` override — i18next
treats `:` as a namespace separator by default:
`t('e.g. https://example.com', { nsSeparator: '|' })`.
- **`npm run i18n` is part of `npm run lint`** — if you add or change a
translation key in source, lint will fail until you run `npm run i18n` and
commit the updated `translation.json`.
- **`npm run i18n:check` is part of `npm run lint`** — if you add or change a
translation key in source, lint will fail until you run `npm run i18n` to
regenerate and commit the updated `translation.json`.

## Permissions

Expand Down
2 changes: 1 addition & 1 deletion apps/ocp-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"dev:proxy": "cd ../../proxy && nodemon --watch 'proxy/**/*' --exec 'go run' app.go --signal SIGTERM",
"dev:ui": "npm run ts-node ../../node_modules/.bin/webpack serve --mode=development --color --progress",
"dev:ocp": "./start-ocp-console.sh",
"lint": "eslint ./src/ && prettier --check './src/**/*.{tsx,ts}' && npm run i18n",
"lint": "eslint ./src/ && prettier --check './src/**/*.{tsx,ts}' && npm run -w @flightctl/i18n i18n:check",
"format": "prettier --check --write './src/**/*.{tsx,ts}'",
"ts-node": "ts-node -O '{\"module\":\"commonjs\"}'"
},
Expand Down
4 changes: 2 additions & 2 deletions apps/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dev:kind": ". ./scripts/setup_env.sh && npm run dev",
"dev:proxy": "cd ../../proxy && nodemon --watch 'proxy/**/*' --exec 'go run' app.go --signal SIGTERM",
"dev:ui": "npm run ts-node ../../node_modules/.bin/webpack serve --mode=development --color --progress",
"lint": "eslint ./src/ && prettier --check './src/**/*.{tsx,ts}' && npm run i18n",
"lint": "eslint ./src/ && prettier --check './src/**/*.{tsx,ts}' && npm run -w @flightctl/i18n i18n:check",
"format": "prettier --check --write './src/**/*.{tsx,ts}'",
"ts-node": "ts-node -O '{\"module\":\"commonjs\"}'"
},
Expand Down Expand Up @@ -51,7 +51,7 @@
"formik": "^2.4.5",
"i18next": "^21.8.14",
"i18next-browser-languagedetector": "^7.2.1",
"i18next-http-backend": "^2.5.0",
"i18next-http-backend": "^4.0.4",
"js-yaml": "^4.3.0",
"monaco-editor": "^0.51.0",
"react": "17.0.1",
Expand Down
6 changes: 4 additions & 2 deletions apps/standalone/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
// Language detection disabled - throws 404 when searching for the user locale translation file.
// Enable this when UI is translated to other languages
// import LanguageDetector from 'i18next-browser-languagedetector';

i18n
// load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales)
Expand All @@ -10,7 +12,7 @@ i18n
.use(Backend)
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector)
//.use(LanguageDetector)
// pass the i18n instance to react-i18next.
.use(initReactI18next)
// init i18next
Expand Down
10 changes: 0 additions & 10 deletions libs/i18n/i18next-parser.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions libs/i18n/i18next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('i18next-cli').I18nextToolkitConfig} */
module.exports = {
locales: ['en'],
extract: {
input: ['../../{libs,apps}/*/src/**/*.{js,jsx,ts,tsx}'],
output: 'locales/{{language}}/{{namespace}}.json',
defaultNS: 'translation',
primaryLanguage: 'en',
keySeparator: false,
nsSeparator: '~',
removeUnusedKeys: true,
// Keep generated catalogs stable between runs.
sort: true,
functions: ['t', '*.t'],
transComponents: ['Trans'],
},
};
Loading
Loading