Add initial l10n setup

This commit is contained in:
shilangyu 2021-02-19 23:23:23 +01:00
parent df2d4d32e8
commit 22b76b0b2b
8 changed files with 54 additions and 3 deletions

View File

@ -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
<!-- TODO -->
## 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

6
l10n.yaml Normal file
View File

@ -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

7
lib/l10n/intl_en.arb Normal file
View File

@ -0,0 +1,7 @@
{
"@@locale": "en",
"addAccount": "Add account",
"@addAccount": {},
"selectInstance": "select instance",
"@selectInstance": {}
}

5
lib/l10n/intl_pl.arb Normal file
View File

@ -0,0 +1,5 @@
{
"@@locale": "pl",
"addAccount": "Dodaj konto",
"selectInstance": "Wybierz instancje"
}

View File

@ -0,0 +1,5 @@
{
"pl": [
"selectInstance"
]
}

View File

@ -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(),
);

View File

@ -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"

View File

@ -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.