Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a64a6ec

Browse files
committed
FluentUI Widgets Localization Support (bdlukaa#216)
2 parents 903ea60 + 2c4f227 commit a64a6ec

27 files changed

+1374
-89
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Date format: DD/MM/YYYY
44

55
- Improves `icons.dart` formatting and its generation.
66
- Fix: [#207](https://github.com/bdlukaa/fluent_ui/pull/207) FilledButton disabled foreground
7+
- NEW: Widgets translated into multiple languages: [#216](https://github.com/bdlukaa/fluent_ui/pull/216)
8+
- Add `useInheritedMediaQuery` property to `FluentApp` [#211](https://github.com/bdlukaa/fluent_ui/pull/211)
79

810
## [3.9.1] - Input Update - [25/02/2022]
911

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ Unofficial implementation of Fluent UI for [Flutter](flutter.dev). It's written
8989
- [Pill Button Bar](#pill-button-bar)
9090
- [Snackbar](#snackbar)
9191
- [Equivalents with the material library](#equivalents-with-the-material-library)
92+
- [Localization](#Localization)
9293
- [Contribution](#contribution)
94+
-[Contributing new localizations](#contributing-new-localizations)
9395
- [Acknowledgements](#acknowledgements)
9496

9597
## Motivation
@@ -1681,12 +1683,40 @@ The list of equivalents between this library and `flutter/material.dart`
16811683
| - | PillButtonBar |
16821684
| ExpansionPanel | Expander |
16831685

1686+
## Localization
1687+
1688+
FluentUI widgets currently supports out-of-the-box an wide number of languages, including:
1689+
1690+
- English
1691+
- French
1692+
- German
1693+
- Hindi
1694+
- Portuguese
1695+
- Russian
1696+
- Simplified Chinese
1697+
- Spanish
1698+
16841699
## Contribution
16851700

16861701
Feel free to [file an issue](https://github.com/bdlukaa/fluent_ui/issues/new) if you find a problem or [make pull requests](https://github.com/bdlukaa/fluent_ui/pulls).
16871702

16881703
All contributions are welcome :)
16891704

1705+
### Contributing new localizations
1706+
1707+
In [PR#216](https://github.com/bdlukaa/fluent_ui/pull/216) we added support for new localizations in FluentUI Widgets.
1708+
1709+
If you want to contribute adding new localizations please follow this steps:
1710+
1711+
- [Fork the repo](https://github.com/bdlukaa/fluent_ui/fork)
1712+
- Copy `lib/l10n/intl_en.arb` file into `lib/l10n` folder with a new language code, following [this list of ISO 859-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
1713+
- Update the contents in the newly created file. Specially, please update the `@locale` value with the corresponding ISO code.
1714+
- Then update the `localization.dart:defaultSupportedLocales` list, adding an entry for each new locale
1715+
- If your IDE doesn't have any of the `intl` plugins ([Intl plugin for Android Studio/IntelliJ](https://plugins.jetbrains.com/plugin/13666-flutter-intl) / [Flutter Intl for VSCode](https://marketplace.visualstudio.com/items?itemName=localizely.flutter-intl) ) please run your project and code generation will take place.
1716+
- When you're done, [make a new pull request](https://github.com/bdlukaa/fluent_ui/pulls)
1717+
1718+
More about [Localization in the Flutter Official Documentation](https://docs.flutter.dev/development/accessibility-and-localization/internationalization)
1719+
16901720
### Acknowledgements
16911721

16921722
Irrespective of order, thanks to all the people below for contributing with the project. It means a lot to me :)

example/pubspec.lock

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ packages:
111111
url: "https://pub.dartlang.org"
112112
source: hosted
113113
version: "1.0.4"
114+
flutter_localizations:
115+
dependency: transitive
116+
description: flutter
117+
source: sdk
118+
version: "0.0.0"
114119
flutter_native_splash:
115120
dependency: "direct dev"
116121
description:

lib/generated/intl/messages_all.dart

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that looks up messages for specific locales by
3+
// delegating to the appropriate library.
4+
5+
// Ignore issues from commonly used lints in this file.
6+
// ignore_for_file:implementation_imports, file_names, unnecessary_new
7+
// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
8+
// ignore_for_file:argument_type_not_assignable, invalid_assignment
9+
// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
10+
// ignore_for_file:comment_references
11+
12+
import 'dart:async';
13+
14+
import 'package:intl/intl.dart';
15+
import 'package:intl/message_lookup_by_library.dart';
16+
import 'package:intl/src/intl_helpers.dart';
17+
18+
import 'messages_de.dart' as messages_de;
19+
import 'messages_en.dart' as messages_en;
20+
import 'messages_es.dart' as messages_es;
21+
import 'messages_fr.dart' as messages_fr;
22+
import 'messages_hi.dart' as messages_hi;
23+
import 'messages_pt.dart' as messages_pt;
24+
import 'messages_ru.dart' as messages_ru;
25+
import 'messages_zh.dart' as messages_zh;
26+
27+
typedef Future<dynamic> LibraryLoader();
28+
Map<String, LibraryLoader> _deferredLibraries = {
29+
'de': () => new Future.value(null),
30+
'en': () => new Future.value(null),
31+
'es': () => new Future.value(null),
32+
'fr': () => new Future.value(null),
33+
'hi': () => new Future.value(null),
34+
'pt': () => new Future.value(null),
35+
'ru': () => new Future.value(null),
36+
'zh': () => new Future.value(null),
37+
};
38+
39+
MessageLookupByLibrary? _findExact(String localeName) {
40+
switch (localeName) {
41+
case 'de':
42+
return messages_de.messages;
43+
case 'en':
44+
return messages_en.messages;
45+
case 'es':
46+
return messages_es.messages;
47+
case 'fr':
48+
return messages_fr.messages;
49+
case 'hi':
50+
return messages_hi.messages;
51+
case 'pt':
52+
return messages_pt.messages;
53+
case 'ru':
54+
return messages_ru.messages;
55+
case 'zh':
56+
return messages_zh.messages;
57+
default:
58+
return null;
59+
}
60+
}
61+
62+
/// User programs should call this before using [localeName] for messages.
63+
Future<bool> initializeMessages(String localeName) async {
64+
var availableLocale = Intl.verifiedLocale(
65+
localeName, (locale) => _deferredLibraries[locale] != null,
66+
onFailure: (_) => null);
67+
if (availableLocale == null) {
68+
return new Future.value(false);
69+
}
70+
var lib = _deferredLibraries[availableLocale];
71+
await (lib == null ? new Future.value(false) : lib());
72+
initializeInternalMessageLookup(() => new CompositeMessageLookup());
73+
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
74+
return new Future.value(true);
75+
}
76+
77+
bool _messagesExistFor(String locale) {
78+
try {
79+
return _findExact(locale) != null;
80+
} catch (e) {
81+
return false;
82+
}
83+
}
84+
85+
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
86+
var actualLocale =
87+
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
88+
if (actualLocale == null) return null;
89+
return _findExact(actualLocale);
90+
}

lib/generated/intl/messages_de.dart

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a de locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
// Ignore issues from commonly used lints in this file.
7+
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
8+
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
9+
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
10+
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
11+
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
12+
13+
import 'package:intl/intl.dart';
14+
import 'package:intl/message_lookup_by_library.dart';
15+
16+
final messages = new MessageLookup();
17+
18+
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
19+
20+
class MessageLookup extends MessageLookupByLibrary {
21+
String get localeName => 'de';
22+
23+
final messages = _notInlinedMessages(_notInlinedMessages);
24+
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
25+
"backButtonTooltip": MessageLookupByLibrary.simpleMessage("Zurück"),
26+
"clickToSearch":
27+
MessageLookupByLibrary.simpleMessage("Zum Suchen klicken"),
28+
"closeButtonLabel": MessageLookupByLibrary.simpleMessage("Schließen"),
29+
"closeNavigationTooltip":
30+
MessageLookupByLibrary.simpleMessage("Navigation schließen"),
31+
"closeTabLabelSuffix":
32+
MessageLookupByLibrary.simpleMessage("Tab schließen"),
33+
"closeWindowTooltip": MessageLookupByLibrary.simpleMessage("Schließen"),
34+
"copyActionLabel": MessageLookupByLibrary.simpleMessage("Kopieren"),
35+
"copyActionTooltip": MessageLookupByLibrary.simpleMessage(
36+
"Ausgewählten Inhalt in die Zwischenablage kopieren"),
37+
"cutActionLabel": MessageLookupByLibrary.simpleMessage("Ausschneiden"),
38+
"cutActionTooltip": MessageLookupByLibrary.simpleMessage(
39+
"Ausgewählten Inhalt entfernen und in die Zwischenablage legen"),
40+
"dialogLabel": MessageLookupByLibrary.simpleMessage("Dialog"),
41+
"minimizeWindowTooltip":
42+
MessageLookupByLibrary.simpleMessage("Minimieren"),
43+
"modalBarrierDismissLabel":
44+
MessageLookupByLibrary.simpleMessage("Schließen"),
45+
"newTabLabel":
46+
MessageLookupByLibrary.simpleMessage("Neuen Tab hinzufügen"),
47+
"noResultsFoundLabel":
48+
MessageLookupByLibrary.simpleMessage("Keine Ergebnisse gefunden"),
49+
"openNavigationTooltip":
50+
MessageLookupByLibrary.simpleMessage("Navigation öffnen"),
51+
"pasteActionLabel": MessageLookupByLibrary.simpleMessage("Einfügen"),
52+
"pasteActionTooltip": MessageLookupByLibrary.simpleMessage(
53+
"Fügt den Inhalt der Zwischenablage an der aktuellen Stelle ein"),
54+
"restoreWindowTooltip":
55+
MessageLookupByLibrary.simpleMessage("Wiederherstellen"),
56+
"scrollTabBackwardLabel": MessageLookupByLibrary.simpleMessage(
57+
"Tab-Liste rückwärts scrollen"),
58+
"scrollTabForwardLabel":
59+
MessageLookupByLibrary.simpleMessage("Tabliste vorwärts scrollen"),
60+
"searchLabel": MessageLookupByLibrary.simpleMessage("Suchen"),
61+
"selectAllActionLabel":
62+
MessageLookupByLibrary.simpleMessage("Alles auswählen"),
63+
"selectAllActionTooltip":
64+
MessageLookupByLibrary.simpleMessage("Alle Inhalte auswählen")
65+
};
66+
}

lib/generated/intl/messages_en.dart

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a en locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
// Ignore issues from commonly used lints in this file.
7+
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
8+
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
9+
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
10+
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
11+
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
12+
13+
import 'package:intl/intl.dart';
14+
import 'package:intl/message_lookup_by_library.dart';
15+
16+
final messages = new MessageLookup();
17+
18+
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
19+
20+
class MessageLookup extends MessageLookupByLibrary {
21+
String get localeName => 'en';
22+
23+
final messages = _notInlinedMessages(_notInlinedMessages);
24+
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
25+
"backButtonTooltip": MessageLookupByLibrary.simpleMessage("Back"),
26+
"clickToSearch":
27+
MessageLookupByLibrary.simpleMessage("Click to search"),
28+
"closeButtonLabel": MessageLookupByLibrary.simpleMessage("Close"),
29+
"closeNavigationTooltip":
30+
MessageLookupByLibrary.simpleMessage("Close Navigation"),
31+
"closeTabLabelSuffix":
32+
MessageLookupByLibrary.simpleMessage("Close tab"),
33+
"closeWindowTooltip": MessageLookupByLibrary.simpleMessage("Close"),
34+
"copyActionLabel": MessageLookupByLibrary.simpleMessage("Copy"),
35+
"copyActionTooltip": MessageLookupByLibrary.simpleMessage(
36+
"Copy the selected content to the clipboard"),
37+
"cutActionLabel": MessageLookupByLibrary.simpleMessage("Cut"),
38+
"cutActionTooltip": MessageLookupByLibrary.simpleMessage(
39+
"Remove the selected content and put it in the clipboard"),
40+
"dialogLabel": MessageLookupByLibrary.simpleMessage("Dialog"),
41+
"minimizeWindowTooltip":
42+
MessageLookupByLibrary.simpleMessage("Minimize"),
43+
"modalBarrierDismissLabel":
44+
MessageLookupByLibrary.simpleMessage("Dismiss"),
45+
"newTabLabel": MessageLookupByLibrary.simpleMessage("Add new tab"),
46+
"noResultsFoundLabel":
47+
MessageLookupByLibrary.simpleMessage("No results found"),
48+
"openNavigationTooltip":
49+
MessageLookupByLibrary.simpleMessage("Open Navigation"),
50+
"pasteActionLabel": MessageLookupByLibrary.simpleMessage("Paste"),
51+
"pasteActionTooltip": MessageLookupByLibrary.simpleMessage(
52+
"Inserts the contents of the clipboard at the current location"),
53+
"restoreWindowTooltip": MessageLookupByLibrary.simpleMessage("Restore"),
54+
"scrollTabBackwardLabel":
55+
MessageLookupByLibrary.simpleMessage("Scroll tab list backward"),
56+
"scrollTabForwardLabel":
57+
MessageLookupByLibrary.simpleMessage("Scroll tab list forward"),
58+
"searchLabel": MessageLookupByLibrary.simpleMessage("Search"),
59+
"selectAllActionLabel":
60+
MessageLookupByLibrary.simpleMessage("Select all"),
61+
"selectAllActionTooltip":
62+
MessageLookupByLibrary.simpleMessage("Select all content")
63+
};
64+
}

lib/generated/intl/messages_es.dart

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a es locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
// Ignore issues from commonly used lints in this file.
7+
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
8+
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
9+
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
10+
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
11+
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
12+
13+
import 'package:intl/intl.dart';
14+
import 'package:intl/message_lookup_by_library.dart';
15+
16+
final messages = new MessageLookup();
17+
18+
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
19+
20+
class MessageLookup extends MessageLookupByLibrary {
21+
String get localeName => 'es';
22+
23+
final messages = _notInlinedMessages(_notInlinedMessages);
24+
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
25+
"backButtonTooltip": MessageLookupByLibrary.simpleMessage("Volver"),
26+
"clickToSearch":
27+
MessageLookupByLibrary.simpleMessage("Haz clic para buscar"),
28+
"closeButtonLabel": MessageLookupByLibrary.simpleMessage("Cerrar"),
29+
"closeNavigationTooltip":
30+
MessageLookupByLibrary.simpleMessage("Cerrar Navegador"),
31+
"closeTabLabelSuffix":
32+
MessageLookupByLibrary.simpleMessage("Cerrar pestaña"),
33+
"closeWindowTooltip": MessageLookupByLibrary.simpleMessage("Cerrar"),
34+
"copyActionLabel": MessageLookupByLibrary.simpleMessage("Copiar"),
35+
"copyActionTooltip": MessageLookupByLibrary.simpleMessage(
36+
"Copiar el contenido seleccionado al portapapeles"),
37+
"cutActionLabel": MessageLookupByLibrary.simpleMessage("Cortar"),
38+
"cutActionTooltip": MessageLookupByLibrary.simpleMessage(
39+
"Cortar el contenido seleccionado y ponerlo en el portapapeles"),
40+
"dialogLabel": MessageLookupByLibrary.simpleMessage("Diálogo"),
41+
"minimizeWindowTooltip":
42+
MessageLookupByLibrary.simpleMessage("Minimizar"),
43+
"modalBarrierDismissLabel":
44+
MessageLookupByLibrary.simpleMessage("Cancelar"),
45+
"newTabLabel":
46+
MessageLookupByLibrary.simpleMessage("Añadir nueva pestaña"),
47+
"noResultsFoundLabel": MessageLookupByLibrary.simpleMessage(
48+
"No se encontraron resultados"),
49+
"openNavigationTooltip":
50+
MessageLookupByLibrary.simpleMessage("Abrir Navegador"),
51+
"pasteActionLabel": MessageLookupByLibrary.simpleMessage("Pegar"),
52+
"pasteActionTooltip": MessageLookupByLibrary.simpleMessage(
53+
"Insertar el contenido del portapapeles en la posición actual"),
54+
"restoreWindowTooltip":
55+
MessageLookupByLibrary.simpleMessage("Restaurar"),
56+
"scrollTabBackwardLabel":
57+
MessageLookupByLibrary.simpleMessage("Hacer scroll hacia atrás"),
58+
"scrollTabForwardLabel":
59+
MessageLookupByLibrary.simpleMessage("Hacer scroll hacia delante"),
60+
"searchLabel": MessageLookupByLibrary.simpleMessage("Buscar"),
61+
"selectAllActionLabel":
62+
MessageLookupByLibrary.simpleMessage("Seleccionar todo"),
63+
"selectAllActionTooltip": MessageLookupByLibrary.simpleMessage(
64+
"Seleccionar todo el contenido")
65+
};
66+
}

0 commit comments

Comments
 (0)