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
6 changes: 6 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
- name: Install dependencies
run: flutter pub get

- name: Generate localization files
run: flutter gen-l10n

- name: Verify generated localization files are committed
run: git diff --exit-code -- lib/l10n/app_localizations.dart lib/l10n/app_localizations_*.dart

- name: Static analysis
run: flutter analyze

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- name: Install dependencies
run: flutter pub get

- name: Generate localization files
run: flutter gen-l10n

- name: Build release APK
run: flutter build apk --release

Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"chat.tools.terminal.autoApprove": {
"Set-Content": true
"Set-Content": true,
"dart": true,
"flutter": true
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
Expand Down
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,36 @@ test/
## Key Conventions

### Localization

- Never hardcode user-visible strings in widgets.
- All strings live in `lib/l10n/app_localizations.dart` in the
`_localizedValues` map, under every supported locale.
- When adding a string, add it under **all** locales (`de`, `en`, etc.).
- The fallback chain is: requested locale → `en` → `de` → fallback param → key.

### Risk scoring

- Base risk is set per `DeviceTemplate.baseRiskScore` in `catalog_data.dart`.
- Per-question penalties are defined in `DeviceInstance.riskScore` (device.dart).
- Score is clamped to `[0, 100]`.
- Child-bedroom room adds a 10-point bonus.
- Dont-know answers use a reduced penalty (roughly half of the "no" penalty).

### Testing

- Run `flutter test` before finishing any task involving core files.
- Run `flutter analyze` to catch static issues.
- When changing risk scoring logic, update `test/device_risk_scoring_test.dart`
with the new expected values.

### Code style

- 2-space indentation, Dart conventions (PascalCase classes, camelCase members).
- Group imports: dart → flutter → package → relative.
- Zero analyzer errors and warnings required.

### Pull request titles

- Pull request titles should follow this template: `<type>: <short description>`.
- Use a lowercase type prefix such as `feat`, `fix`, `docs`, `refactor`, `test`, or `chore`.
- Examples: `feat: add summary export`, `fix: preserve selected room state`.
Expand Down
29 changes: 22 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ lib/
- `lib/models/survey_state.dart`: central assessment state and local persistence
- `lib/screens/`: wizard flow screens and summary screen
- `lib/widgets/`: reusable UI components
- `lib/l10n/app_localizations.dart`: localization source of truth
- `lib/l10n/*.arb`: localization source of truth (generated Dart files are derived from ARB)

### State and persistence

Expand Down Expand Up @@ -161,11 +161,25 @@ Target: zero analyzer errors and warnings.
### Localization requirements

- Do not hardcode user-facing text in widgets.
- Localization source of truth is `lib/l10n/app_localizations.dart`.
- Add or update keys consistently across supported locales.
- Verify fallback behavior for missing locale values.
- Localization source of truth is the ARB files in `lib/l10n/`.
- Add or update keys consistently across supported locale ARB files.
- Regenerate localization code with `flutter gen-l10n` after ARB changes.
- Ensure summary export helpers still receive localized strings.

### Localization workflow

When adding or changing user-facing strings:

1. Add/update the key in `lib/l10n/app_en.arb`.
2. Add/update the same key in all other locale files in `lib/l10n/` (`app_de.arb`, `app_cs.arb`, `app_pl.arb`, `app_fr.arb`, `app_nl.arb`, `app_da.arb`).
3. Regenerate generated localization classes:

```bash
flutter gen-l10n
```

4. Commit ARB + generated localization Dart files together.

### Comments

- Explain why, not what.
Expand Down Expand Up @@ -247,13 +261,14 @@ Typical changes:

Primary files:

- `lib/l10n/app_localizations.dart`
- `lib/l10n/app_en.arb`
- `lib/l10n/app_*.arb`
- relevant UI files consuming localized strings

Typical changes:

- Add translation keys and values
- Ensure fallback behavior remains correct
- Add/update translation keys and values in all locale ARB files
- Run `flutter gen-l10n` and commit generated files
- Verify exports and summaries remain localized

### 5. Improve documentation
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ The app targets Android, iOS, Web, Windows, macOS, and Linux.

All developer setup, architecture notes, code standards, and contribution workflow are documented in [CONTRIBUTING.md](CONTRIBUTING.md).

### Localization workflow (contributors)

1. Add the new key in `lib/l10n/app_en.arb`.
2. Add translations for the same key in every other ARB file in `lib/l10n/` (`app_de.arb`, `app_cs.arb`, `app_pl.arb`, `app_fr.arb`, `app_nl.arb`, `app_da.arb`).
3. Regenerate localization code:

```bash
flutter gen-l10n
```

4. Commit the ARB changes and generated `lib/l10n/app_localizations*.dart` files together.

Risk scoring details (formula, thresholds, weights, and rationale) are documented in [lib/models/RISK_SCORING_README.md](lib/models/RISK_SCORING_README.md).

## License
Expand Down
5 changes: 5 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-dir: lib/l10n
output-localization-file: app_localizations.dart
output-class: AppLocalizations
4 changes: 2 additions & 2 deletions lib/data/catalog_data.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../l10n/localization_lookup.dart';
import '../models/room.dart';
import '../models/device.dart';

class CatalogData {
static String localizeText(String source) =>
AppLocalizations.translate(source);
LocalizationLookup.translate(source);

static String roomName(Room room) => localizeText(room.name);

Expand Down
Loading
Loading