Skip to content

Commit

Permalink
Merge pull request #12 from Floating-Dartists/feat/localization
Browse files Browse the repository at this point in the history
Feat/localization
  • Loading branch information
TesteurManiak committed Dec 20, 2023
2 parents d9fc434 + ae8535d commit f987016
Show file tree
Hide file tree
Showing 59 changed files with 1,076 additions and 547 deletions.
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},
};
}

0 comments on commit f987016

Please sign in to comment.