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

Feat/localization #12

Merged
merged 11 commits into from
Dec 20, 2023
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
56 changes: 13 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ The full design specifications is available here: https://www.figma.com/@gouvfr

**This project is not affiliated with the french government.**

## Table of Contents

- [Getting Started](#getting-started)
- [Components](#components)
- [Buttons](#buttons)
- [Alerts](#alerts)
- [Accordion](#accordion)
- [Badges](#badges)
- [ButtonsGroup](#buttongroup)
- [Banners](#banners)
- [Radio](#radio)
- [Contributors](#contributors)

## Getting Started

* Add the package to your `pubspec.yaml` file:
Expand Down Expand Up @@ -244,49 +257,6 @@ DSFRRadioGroupFormField<bool>(

![radio_group.png](https://raw.githubusercontent.com/Floating-Dartists/flutter_dsfr/main/screenshots/radio_group.png)

## Roadmap

Components we need to implement

- [X] Accordion
- [ ] FileUpload
- [X] Alerts
- [X] Badges
- [X] Banner
- [ ] SearchBar
- [X] Buttons
- [X] ButtonsGroup
- [X] FranceConnectButton
- [X] Radio
- [ ] RichRadio
- [ ] Checkbox
- [ ] Card
- [ ] Input
- [ ] Quote
- [ ] Header
- [ ] Breadcrumb
- [ ] ConscentBanner
- [ ] StepIndicateur
- [ ] ToggleSwitch
- [ ] Links
- [ ] SkipLinks
- [ ] Select
- [ ] SideMenu
- [ ] Callout
- [ ] Highlight
- [ ] Modal
- [ ] MainNavigation
- [ ] Tabs
- [ ] Display
- [ ] Share
- [ ] Footer
- [ ] Pagination
- [ ] Summary
- [ ] Table
- [ ] Tag
- [ ] DownloadFile
- [ ] Tile

## Contributors

<!-- readme: contributors -start -->
Expand Down
63 changes: 2 additions & 61 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,5 @@
include: package:flutter_lints/flutter.yaml
include: package:fd_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
exclude:
- lib/**.g.dart
- test/**.mocks.dart
- lib/generated_plugin_registrant.dart
errors:
missing_required_param: error
unrelated_type_equality_checks: error
missing_return: warning
close_sinks: warning
cancel_subscriptions: warning
parameter_assignments: warning
prefer_final_in_for_each: warning
prefer_mixin: warning
unawaited_futures: warning
unnecessary_await_in_return: warning
unnecessary_null_aware_assignments: warning
use_decorated_box: warning
use_string_buffers: warning
avoid_unnecessary_containers: warning
use_if_null_to_convert_nulls_to_bools: warning

linter:
rules:
- always_declare_return_types
- avoid_bool_literals_in_conditional_expressions
- avoid_escaping_inner_quotes
- avoid_positional_boolean_parameters
- parameter_assignments
- prefer_null_aware_method_calls
- require_trailing_commas
- use_is_even_rather_than_modulo
- use_named_constants
- use_to_and_as_if_applicable
- prefer_relative_imports
- avoid_unused_constructor_parameters
- sort_child_properties_last
- directives_ordering
- close_sinks
- cancel_subscriptions
- unnecessary_statements
- avoid_annotating_with_dynamic
- prefer_final_locals
- prefer_final_in_for_each
- prefer_interpolation_to_compose_strings
- prefer_mixin
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_parenthesis
- unnecessary_raw_strings
- use_decorated_box
- use_if_null_to_convert_nulls_to_bools
- use_string_buffers
- avoid_unnecessary_containers
- use_build_context_synchronously
- use_super_parameters
- "lib/src/components/logo/logo.dart"
62 changes: 62 additions & 0 deletions bin/add_label.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'dart:convert';
import 'dart:io';

import 'package:path/path.dart' as path;

Future<void> main(List<String> args) async {
final name = prompt('Label name');
final cwd = Directory.current.path;
final l10nSrc = Directory(path.join(cwd, 'lib', 'l10n'));

final frArb = File(path.join(l10nSrc.path, 'flutter_dsfr_fr.arb'));
final frContent =
jsonDecode(await frArb.readAsString()) as Map<String, dynamic>;

if (frContent.containsKey(name)) {
stderr.writeln('Label "$name" already exists');
exit(1);
}

final description = prompt('Label description');
final frTranslation = prompt('French translation');

final files = l10nSrc.listSync().whereType<File>().toList();
final futures = files.map((file) async {
final newContent = await addLabel(file, name, description, frTranslation);
final b = StringBuffer();
final string = const JsonEncoder.withIndent(' ').convert(newContent);
b
..write(string)
..writeln();

await file.writeAsString(b.toString());
});

await Future.wait(futures);
stdout.writeln('Done!');
}

String prompt(String tag) {
stdout.write('$tag?: ');
final answer = stdin.readLineSync();
if (answer == null || answer.isEmpty) {
throw Exception('$tag is required');
}
return answer;
}

Future<Map<String, dynamic>> addLabel(
File file,
String name,
String description,
String frTranslation,
) async {
final content = jsonDecode(await file.readAsString()) as Map<String, dynamic>;

return {
...content,
"@@last_modified": DateTime.now().toIso8601String(),
name: frTranslation,
"@$name": {"description": description},
};
}
Loading
Loading