blob: 075ba759428ada40706dec9df13aa55853c508ce [file] [log] [blame] [view]
Greg Spencerca713552020-06-30 09:15:04 -07001# Flutter Framework localizations
2
3This package contains the localizations used by the Flutter framework
4itself.
5
6See the [localization README](./lib/src/README.md) for more detailed
7information about the localizations themselves.
8
9## Adding a new string to localizations
10
11If you (someone contributing to the Flutter framework) want to add a new
12string to the `MaterialLocalizations`, `WidgetsLocalizations` or the
13`CupertinoLocalizations` objects (e.g. because you've added a new widget
14and it has a tooltip), follow these steps (these instructions are for
15`MaterialLocalizations`, but apply equally to `CupertinoLocalizations`
16and `WidgetsLocalizations`, with appropriate name substitutions):
17
181. Add the new getter to the localizations class `MaterialLocalizations`,
19 in `flutter_localizations/lib/src/material_localizations.dart`.
20
212. Implement a default value in `DefaultMaterialLocalizations` in
22 `flutter_localizations/lib/src/material_localizations.dart`
23
243. Add a test to `test/material/localizations_test.dart` that verifies that
25 this new value is implemented.
26
274. Update the `flutter_localizations` package. To add a new string to the
28 `flutter_localizations` package, you must first add it to the English
29 translations (`lib/src/l10n/material_en.arb`), including a description.
30
31 Then you need to add new entries for the string to all of the other
32 language locale files by running:
33 ```
34 dart dev/tools/localization/bin/gen_missing_localizations.dart
35 ```
36 Which will copy the english strings into the other locales as placeholders
37 until they can be translated.
38
39 Finally you need to re-generate lib/src/l10n/localizations.dart by running:
40 ```
41 dart dev/tools/localization/bin/gen_localizations.dart --overwrite
42 ```
43
44 There is a [localization README](./lib/src/README.md) file with further
45 information in the `lib/src/l10n/` directory.
46
475. If you are a Google employee, you should then also follow the instructions
48 at `go/flutter-l10n`. If you're not, don't worry about it.
49
50## Updating an existing string
51
52If you or someone contributing to the Flutter framework wants to modify an
53existing string in the MaterialLocalizations objects, follow these steps:
54
551. Modify the default value of the relevant getter(s) in
56 `DefaultMaterialLocalizations` below.
57
582. Update the `flutter_localizations` package. Modify the out-of-date English
59 strings in `lib/src/l10n/material_en.arb`.
60
61 You also need to re-generate `lib/src/l10n/localizations.dart` by running:
62 ```
63 dart dev/tools/localization/bin/gen_localizations.dart --overwrite
64 ```
65
66 This script may result in your updated getters being created in newer
67 locales and set to the old value of the strings. This is to be expected.
68 Leave them as they were generated, and they will be picked up for
69 translation.
70
71 There is a [localization README](./lib/src/README.md) file with further
72 information in the `lib/src/l10n/` directory.
73
743. If you are a Google employee, you should then also follow the instructions
75 at `go/flutter-l10n`. If you're not, don't worry about it.