Skip to content

Commit 0696756

Browse files
committed
intl: Set up basic i18n framework
Set up `flutter_localizations` integration and add initial test bundle of ARB files to support some strings found in the profile page. The bindings are autogenerated on `flutter run`. Fixes zulip#275
1 parent d92a018 commit 0696756

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

l10n.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
arb-dir: lib/l10n
2+
template-arb-file: app_en.arb
3+
output-class: ZulipLocalizations
4+
output-localization-file: zulip_localizations.dart

lib/l10n/app_en.arb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"buttonSendDirectMessage": "Send direct message",
3+
"@buttonSendDirectMessage": {
4+
"description": "Label for button in profile screen to navigate to DMs with the shown user."
5+
},
6+
"userRoleOwner": "Owner",
7+
"@userRoleOwner": {
8+
"description": "Label for UserRole.owner"
9+
},
10+
"userRoleAdministrator": "Administrator",
11+
"@userRoleAdministrator": {
12+
"description": "Label for UserRole.administrator"
13+
},
14+
"userRoleModerator": "Moderator",
15+
"@userRoleModerator": {
16+
"description": "Label for UserRole.moderator"
17+
},
18+
"userRoleMember": "Member",
19+
"@userRoleMember": {
20+
"description": "Label for UserRole.member"
21+
},
22+
"userRoleGuest": "Guest",
23+
"@userRoleGuest": {
24+
"description": "Label for UserRole.guest"
25+
},
26+
"userRoleUnknown": "Unknown",
27+
"@userRoleUnknown": {
28+
"description": "Label for UserRole.unknown"
29+
}
30+
}

lib/l10n/app_ja.arb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"buttonSendDirectMessage": "ダイレクトメッセージを送信",
3+
"userRoleOwner": "オーナー",
4+
"userRoleAdministrator": "管理者",
5+
"userRoleModerator": "モデレータ",
6+
"userRoleMember": "メンバー",
7+
"userRoleGuest": "ゲスト",
8+
"userRoleUnknown": "不明"
9+
}

lib/widgets/app.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
23

34
import '../model/narrow.dart';
45
import 'about_zulip.dart';
@@ -45,6 +46,8 @@ class ZulipApp extends StatelessWidget {
4546
return GlobalStoreWidget(
4647
child: MaterialApp(
4748
title: 'Zulip',
49+
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
50+
supportedLocales: ZulipLocalizations.supportedLocales,
4851
theme: theme,
4952
home: const ChooseAccountPage()));
5053
}

pubspec.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ packages:
358358
url: "https://pub.dev"
359359
source: hosted
360360
version: "2.0.2"
361+
flutter_localizations:
362+
dependency: "direct main"
363+
description: flutter
364+
source: sdk
365+
version: "0.0.0"
361366
flutter_plugin_android_lifecycle:
362367
dependency: transitive
363368
description:

pubspec.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ dependencies:
5757
package_info_plus: ^4.0.1
5858
collection: ^1.17.2
5959
url_launcher: ^6.1.11
60+
flutter_localizations:
61+
sdk: flutter
6062

6163
dev_dependencies:
6264
flutter_test:
@@ -82,6 +84,11 @@ dev_dependencies:
8284
# The following section is specific to Flutter packages.
8385
flutter:
8486

87+
# Generate localization bindings from ARB files in lib/l10n/.
88+
# This happens automatically with `flutter run`
89+
# but can be manually run with `flutter gen-l10n`
90+
generate: true
91+
8592
# The following line ensures that the Material Icons font is
8693
# included with your application, so that you can use the icons in
8794
# the material Icons class.

0 commit comments

Comments
 (0)