Skip to content

Commit 5358807

Browse files
authored
Migrate to flutter_localizations (#1522)
* Migrate to flutter_localizations * Update documentation and remove unused parameters * Update automated publishing * Add development notes page * Update to flutter_quill/translations.dart * Remove unused package * Fix missing translations
1 parent 7076e20 commit 5358807

File tree

119 files changed

+11749
-2529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+11749
-2529
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ jobs:
3131
# Here you can insert custom steps you need
3232
# - run: dart tool/generate-code.dart
3333

34+
- name: Re-generate the translations
35+
run: ./scripts/renegerate-translations.sh
36+
3437
- name: Publish
3538
run: flutter pub publish --force

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [8.5.0]
2+
- Migrate to `flutter_localizations` for the translations
3+
- Fix: Translate all the untranslated localizations
4+
- Fix: Translate missing translations
5+
- Fix: Add default Chinese fallback translation
6+
- Remove: unused parameters `items` in `QuillToolbarFontFamilyButtonOptions` and `QuillToolbarFontSizeButtonOptions`
7+
- Update: documentation
8+
19
## [8.4.4]
210
- Update `.pubignore` to ignore unnecessary files and folders
311

README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,21 @@
2626

2727
FlutterQuill is a rich text editor and a [Quill] component for [Flutter].
2828

29-
This library is a WYSIWYG editor built for the modern Android, iOS, web and desktop platforms. Check out our [Youtube Playlist] or [Code Introduction] to take a detailed walkthrough of the code base. You can join our [Slack Group] for discussion.
29+
This library is a WYSIWYG editor built for the modern Android, iOS, web and desktop platforms. Check out our [Youtube Playlist] or [Code Introduction](./doc/code_introduction.md) to take a detailed walkthrough of the code base. You can join our [Slack Group] for discussion.
3030

3131
Pub: [FlutterQuill]
3232

3333
## Table of contents
3434
- [Flutter Quill](#flutter-quill)
3535
- [Table of contents](#table-of-contents)
3636
- [Installation](#installation)
37+
- [Screenshots](#screenshots)
3738
- [Usage](#usage)
3839
- [Migration](#migration)
3940
- [Input / Output](#input--output)
4041
- [Configurations](#configurations)
4142
- [Using Custom App Widget](#using-custom-app-widget)
43+
- [Localizations setup](#localizations-setup)
4244
- [Font Size](#font-size)
4345
- [Font Family](#font-family)
4446
- [Custom Buttons](#custom-buttons)
@@ -75,6 +77,20 @@ dependencies:
7577
> If the latest version of [FlutterQuill Extensions] is pre-release, then please use it in order to work with the latest stable version of [FlutterQuill]
7678
>
7779
80+
## Screenshots
81+
82+
<details>
83+
<summary>Tap to show/hide screenshots</summary>
84+
85+
<br>
86+
87+
<img src="./example/assets/images/1.png" width="150" alt="Screenshot 1">
88+
<img src="./example/assets/images/2.png" width="150" alt="Screenshot 2">
89+
<img src="./example/assets/images/3.png" width="150" alt="Screenshot 3">
90+
<img src="./example/assets/images/4.png" width="150" alt="Screenshot 4">
91+
92+
</details>
93+
7894
## Usage
7995
8096
See the `example` directory for a minimal example of how to use FlutterQuill. You typically just need to instantiate a controller:
@@ -176,10 +192,36 @@ localizationsDelegates: const [
176192
],
177193
```
178194

179-
in addition to the required delegates by this library
180-
181195
Note: In the latest versions of `FluentApp` you no longer need to add the `localizationsDelegates` but this is just an example, for more [info](https://github.com/bdlukaa/fluent_ui/pull/946)
182196

197+
There are additonal notes in [Localizations](#localizations) section
198+
199+
### Localizations setup
200+
in addition to the required delegatess which mentioned above in [Using custom app widget](#using-custom-app-widget)
201+
202+
which are:
203+
```dart
204+
localizationsDelegates: const [
205+
DefaultCupertinoLocalizations.delegate,
206+
DefaultMaterialLocalizations.delegate,
207+
DefaultWidgetsLocalizations.delegate,
208+
],
209+
```
210+
which are used by offical flutter widgets
211+
212+
The library also needs the
213+
```dart
214+
// Required localizations delegates ...
215+
FlutterQuillLocalizations.delegate
216+
```
217+
218+
To offer the default localizations.
219+
220+
But **you don't have to** since we have wraped the `QuillEditor` and `QuillToolbar` with `FlutterQuillLocalizationsWidget` which will check if it sets then it will go, if not, then it will be provided only for them, so it's not really required, but if you are overriding the `localizationsDelegates` you could also add the `FlutterQuillLocalizations.delegate`
221+
which won't change anything
222+
223+
please read the [Translation](./doc/translation.md) section
224+
183225
### Font Size
184226

185227
Within the editor toolbar, a drop-down with font-sizing capabilities is available. This can be enabled or disabled with `showFontSize`.
@@ -302,6 +344,8 @@ We welcome contributions!
302344

303345
Please follow these guidelines when contributing to the project. See [CONTRIBUTING.md](./doc/CONTRIBUTING.md) for more details. <br>
304346

347+
We must mention that the `CONTRIBUTING.md` have a development notes, so if you planning on contribtuing to the repo, please read it.
348+
305349
You can check the [Todo](./doc/todo.md) list if you want to
306350

307351
[Quill]: https://quilljs.com/docs/formats
@@ -312,6 +356,6 @@ You can check the [Todo](./doc/todo.md) list if you want to
312356
[Youtube Playlist]: https://youtube.com/playlist?list=PLbhaS_83B97vONkOAWGJrSXWX58et9zZ2
313357
[Slack Group]: https://join.slack.com/t/bulletjournal1024/shared_invite/zt-fys7t9hi-ITVU5PGDen1rNRyCjdcQ2g
314358
[Sample Page]: https://github.com/singerdmx/flutter-quill/blob/master/example/lib/pages/home_page.dart
315-
[Code Introduction]: https://github.com/singerdmx/flutter-quill/blob/master/doc/CodeIntroduction.md
359+
<!-- [Code Introduction]: https://github.com/singerdmx/flutter-quill/blob/master/doc/code_introduction.md -->
316360
[FluentUI]: https://pub.dev/packages/fluent_ui
317361

doc/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ git push origin your-branch-name
5959
```
6060
6161
Thank you for your time and efforts in this open-source community project!!
62+
63+
## Development Notes
64+
Please read the [Development Notes](./development_notes.md) as they are important while development
File renamed without changes.

doc/development_notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Development notes
2+
3+
- When update the translations or localizations in the app, please take a look at the [Translation](./translation.md) page as it have important notes in order to work, if you also adding a feature that add new localizations then you need to the instructions of it in order for the translations to take affect

doc/readme/cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
---
2626

27-
> This documentation is outdated. Please check the English version.
27+
> This documentation is outdated. Please check the [English version](../../README.md).
2828
2929
`FlutterQuill` 是一个富文本编辑器,也是 [Quill](https://quilljs.com/docs/formats)[Flutter](https://github.com/flutter/flutter) 的版本
3030

doc/translation.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Translation
22

3-
The package offers translations for the quill toolbar and editor, it will follow the system locale unless you set your own locale with:
3+
The package offers translations for the quill toolbar and editor, it will follow the locale that is defined in your `WidgetsApp` for example `MaterialApp` which usually follow the system local and it unless you set your own locale with:
44

55
```dart
66
QuillProvider(
77
configurations: QuillConfigurations(
88
controller: _controller,
99
sharedConfigurations: const QuillSharedConfigurations(
10-
locale: Locale('fr'),
10+
locale: Locale('fr'), // will take affect only if FlutterQuillLocalizations.delegate is not defined in the Widget app
1111
),
1212
),
1313
child: Column(
@@ -38,4 +38,27 @@ Currently, translations are available for these 31 locales:
3838

3939
#### Contributing to translations
4040

41-
The translation file is located at [toolbar.i18n.dart](lib/src/translations/toolbar.i18n.dart). Feel free to contribute your own translations, just copy the English translations map and replace the values with your translations. Then open a pull request so everyone can benefit from your translations!
41+
The translation files is located at [l10n folder](../lib/src/l10n/). Feel free to contribute your own translations, just copy the [English translations](../lib/src/l10n/quill_en.arb) map and replace the values with your translations.
42+
43+
Add new file in the l10n folder with the following name
44+
`quill_${localName}.arb` for example `quill_de.arb`
45+
paste the English version and replace the values
46+
47+
Also you can take a look at the [untranslated](../lib/src/l10n/untranslated.json) json file, which is a generated file that tell you which keys hasn't with which locales hasn't translated so you can translate the missings
48+
49+
After you are done and want to test the changes, run the following in the root folder (preferred):
50+
51+
```
52+
flutter gen-l10n
53+
```
54+
55+
or:
56+
57+
```
58+
./scripts/renegerate-translations.sh
59+
```
60+
61+
62+
This will generate the new dart files from the arb files in order to take affect, otherwise you won't notice a difference
63+
64+
Then open a pull request so everyone can benefit from your translations!

example/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ linter:
1111
annotate_overrides: true
1212
avoid_empty_else: true
1313
avoid_escaping_inner_quotes: true
14-
avoid_print: true
14+
avoid_print: false
1515
avoid_redundant_argument_values: true
1616
avoid_types_on_closure_parameters: true
1717
avoid_void_async: true

example/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_localizations/flutter_localizations.dart';
3+
import 'package:flutter_quill/translations.dart';
34

45
import 'pages/home_page.dart';
56

@@ -32,11 +33,10 @@ class MyApp extends StatelessWidget {
3233
GlobalMaterialLocalizations.delegate,
3334
GlobalWidgetsLocalizations.delegate,
3435
GlobalCupertinoLocalizations.delegate,
36+
FlutterQuillLocalizations.delegate,
3537
],
36-
supportedLocales: const [
37-
Locale('en', 'US'),
38-
Locale('zh', 'HK'),
39-
],
38+
locale: const Locale('ar'),
39+
supportedLocales: FlutterQuillLocalizations.supportedLocales,
4040
home: const HomePage(),
4141
);
4242
}

0 commit comments

Comments
 (0)