Add initial l10n setup
This commit is contained in:
parent
df2d4d32e8
commit
22b76b0b2b
|
@ -6,6 +6,14 @@
|
||||||
|
|
||||||
From issues to wikis: everything is on [GitHub](https://github.com/krawieck/lemmur)
|
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
|
||||||
|
|
||||||
|
<!-- TODO -->
|
||||||
|
|
||||||
## Architecture
|
## 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.
|
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/`)
|
(relative to `lib/`)
|
||||||
|
|
||||||
- `hooks/`: reusable state hooks
|
- `hooks/`: reusable state hooks
|
||||||
|
- `l10n/`: files with localized strings and localizations tools
|
||||||
- `pages/`: fullscreen pages that you navigate to
|
- `pages/`: fullscreen pages that you navigate to
|
||||||
- `stores/`: global stores
|
- `stores/`: global stores
|
||||||
- `util/`: utilities
|
- `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
|
- 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
|
- 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
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"@@locale": "en",
|
||||||
|
"addAccount": "Add account",
|
||||||
|
"@addAccount": {},
|
||||||
|
"selectInstance": "select instance",
|
||||||
|
"@selectInstance": {}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"@@locale": "pl",
|
||||||
|
"addAccount": "Dodaj konto",
|
||||||
|
"selectInstance": "Wybierz instancje"
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"pl": [
|
||||||
|
"selectInstance"
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -42,8 +43,11 @@ class MyApp extends HookWidget {
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'lemmur',
|
title: 'lemmur',
|
||||||
|
supportedLocales: L10n.supportedLocales,
|
||||||
|
localizationsDelegates: L10n.localizationsDelegates,
|
||||||
themeMode: configStore.theme,
|
themeMode: configStore.theme,
|
||||||
darkTheme: configStore.amoledDarkMode ? amoledTheme : darkTheme,
|
darkTheme: configStore.amoledDarkMode ? amoledTheme : darkTheme,
|
||||||
|
locale: configStore.locale,
|
||||||
theme: lightTheme,
|
theme: lightTheme,
|
||||||
home: const MyHomePage(),
|
home: const MyHomePage(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -258,6 +258,11 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.1"
|
version: "0.8.1"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_markdown:
|
flutter_markdown:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -367,7 +372,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.6"
|
version: "1.1.6"
|
||||||
intl:
|
intl:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
|
|
@ -45,11 +45,14 @@ dependencies:
|
||||||
timeago: ^2.0.27
|
timeago: ^2.0.27
|
||||||
fuzzy: <1.0.0
|
fuzzy: <1.0.0
|
||||||
lemmy_api_client: ^0.12.0
|
lemmy_api_client: ^0.12.0
|
||||||
|
intl: ^0.16.1
|
||||||
matrix4_transform: ^1.1.7
|
matrix4_transform: ^1.1.7
|
||||||
json_annotation: ^3.1.1
|
json_annotation: ^3.1.1
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
@ -74,6 +77,7 @@ flutter_icons:
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
# The following section is specific to Flutter.
|
# The following section is specific to Flutter.
|
||||||
flutter:
|
flutter:
|
||||||
|
generate: true
|
||||||
# The following line ensures that the Material Icons font is
|
# The following line ensures that the Material Icons font is
|
||||||
# included with your application, so that you can use the icons in
|
# included with your application, so that you can use the icons in
|
||||||
# the material Icons class.
|
# the material Icons class.
|
||||||
|
|
Loading…
Reference in New Issue