diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b19e517..4a5345b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,14 @@ From issues to wikis: everything is on [GitHub](https://github.com/krawieck/lemmur) +## Linting / Formatting + +Everything is formatted with `dartfmt` (no flags) and linted with `dartanalyzer` ([see rules](analysis_options.yaml)). Both are enforced by the CI. + +## Translations + + + ## Architecture Lemmur is written in Dart using [Flutter](https://flutter.dev/docs). To communicate with Lemmy instances [lemmy_api_client](https://github.com/krawieck/lemmy_api_client) is used. @@ -19,6 +27,7 @@ Lemmur is written in Dart using [Flutter](https://flutter.dev/docs). To communic (relative to `lib/`) - `hooks/`: reusable state hooks +- `l10n/`: files with localized strings and localizations tools - `pages/`: fullscreen pages that you navigate to - `stores/`: global stores - `util/`: utilities @@ -30,6 +39,12 @@ Lemmur is written in Dart using [Flutter](https://flutter.dev/docs). To communic - Be aware that Lemmur supports arbitrary Lemmy instances, don't hardcode instance urls - Remember that a user is not obligated to be logged in, contributed widgets should handle this case -## Linting / Formatting +### For React developers -Everything is formatted with `dartfmt` (no flags) and linted with `dartanalyzer` ([see rules](analysis_options.yaml)). Both are enforced by the CI. +If you come from a React background Flutter shouldn't be anything hard to grasp for you. + +- Components are called 'widgets' in flutter +- `flutter_hooks` is a React hooks port to flutter. Though you will come to see that `flutter_hooks` are not as powerful +- There is no CSS. You compose your layout with other widgets and style them by passing properties to them +- There are no functional components, everything has to be a class +- Creating wrapping widgets is not as nice as in React, there is no `{ ...props }`. In flutter you need to pass each argument one by one diff --git a/l10n.yaml b/l10n.yaml new file mode 100644 index 0000000..3dfa015 --- /dev/null +++ b/l10n.yaml @@ -0,0 +1,6 @@ +arb-dir: lib/l10n +template-arb-file: intl_en.arb +output-localization-file: l10n.dart +preferred-supported-locales: [en] +output-class: L10n +untranslated-messages-file: lib/l10n/untranslated.json diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb new file mode 100644 index 0000000..3955de7 --- /dev/null +++ b/lib/l10n/intl_en.arb @@ -0,0 +1,7 @@ +{ + "@@locale": "en", + "addAccount": "Add account", + "@addAccount": {}, + "selectInstance": "select instance", + "@selectInstance": {} +} diff --git a/lib/l10n/intl_pl.arb b/lib/l10n/intl_pl.arb new file mode 100644 index 0000000..814ef18 --- /dev/null +++ b/lib/l10n/intl_pl.arb @@ -0,0 +1,5 @@ +{ + "@@locale": "pl", + "addAccount": "Dodaj konto", + "selectInstance": "Wybierz instancje" +} diff --git a/lib/l10n/untranslated.json b/lib/l10n/untranslated.json new file mode 100644 index 0000000..53bb22f --- /dev/null +++ b/lib/l10n/untranslated.json @@ -0,0 +1,5 @@ +{ + "pl": [ + "selectInstance" + ] +} diff --git a/lib/main.dart b/lib/main.dart index cb6b231..ee5a443 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:provider/provider.dart'; @@ -42,8 +43,11 @@ class MyApp extends HookWidget { return MaterialApp( title: 'lemmur', + supportedLocales: L10n.supportedLocales, + localizationsDelegates: L10n.localizationsDelegates, themeMode: configStore.theme, darkTheme: configStore.amoledDarkMode ? amoledTheme : darkTheme, + locale: configStore.locale, theme: lightTheme, home: const MyHomePage(), ); diff --git a/pubspec.lock b/pubspec.lock index c63d8b1..23cfed2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -258,6 +258,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.8.1" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_markdown: dependency: "direct main" description: @@ -367,7 +372,7 @@ packages: source: hosted version: "1.1.6" intl: - dependency: transitive + dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index 59d71ef..ad45742 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,11 +45,14 @@ dependencies: timeago: ^2.0.27 fuzzy: <1.0.0 lemmy_api_client: ^0.12.0 + intl: ^0.16.1 matrix4_transform: ^1.1.7 json_annotation: ^3.1.1 flutter: sdk: flutter + flutter_localizations: + sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. @@ -74,6 +77,7 @@ flutter_icons: # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: + generate: true # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class.