Skip to content

Commit f58ff49

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 in different contexts. The bindings are autogenerated on `flutter run`. Fixes #275
1 parent 744c1f8 commit f58ff49

File tree

6 files changed

+96
-0
lines changed

6 files changed

+96
-0
lines changed

l10n.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
arb-dir: lib/l10n
2+
template-arb-file: app_en.arb
3+
output-localization-file: zulip_localizations.dart
4+
output-class: ZulipLocalizations
5+
preferred-supported-locales: [ en ]
6+
nullable-getter: false

lib/l10n/app_en.arb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"chooseAccountPageTitle": "Choose account",
3+
"@chooseAccountPageTitle": {
4+
"description": "Title for ChooseAccountPage"
5+
},
6+
"chooseAccountButtonAddAnAccount": "Add an account",
7+
"@chooseAccountButtonAddAnAccount": {
8+
"description": "Label for ChooseAccountPage button to add an account"
9+
},
10+
"profileButtonSendDirectMessage": "Send direct message",
11+
"@profileButtonSendDirectMessage": {
12+
"description": "Label for button in profile screen to navigate to DMs with the shown user."
13+
},
14+
"cameraAccessDeniedTitle": "Permissions needed",
15+
"@cameraAccessDeniedTitle": {
16+
"description": "Title for dialog when the user needs to grant permissions for camera access."
17+
},
18+
"cameraAccessDeniedMessage": "To upload an image, please grant Zulip additional permissions in Settings.",
19+
"@cameraAccessDeniedMessage": {
20+
"description": "Message for dialog when the user needs to grant permissions for camera access."
21+
},
22+
"cameraAccessDeniedButtonText": "Open settings",
23+
"@cameraAccessDeniedButtonText": {
24+
"description": "Message for dialog when the user needs to grant permissions for camera access."
25+
},
26+
"subscribedToNStreams": "Subscribed to {num, plural, =0{no streams} =1{1 stream} other{{num} streams}}",
27+
"@subscribedToNStreams": {
28+
"description": "Test page label showing number of streams user is subscribed to.",
29+
"placeholders": {
30+
"num": {
31+
"type": "int",
32+
"example": "4"
33+
}
34+
}
35+
},
36+
"userRoleOwner": "Owner",
37+
"@userRoleOwner": {
38+
"description": "Label for UserRole.owner"
39+
},
40+
"userRoleAdministrator": "Administrator",
41+
"@userRoleAdministrator": {
42+
"description": "Label for UserRole.administrator"
43+
},
44+
"userRoleModerator": "Moderator",
45+
"@userRoleModerator": {
46+
"description": "Label for UserRole.moderator"
47+
},
48+
"userRoleMember": "Member",
49+
"@userRoleMember": {
50+
"description": "Label for UserRole.member"
51+
},
52+
"userRoleGuest": "Guest",
53+
"@userRoleGuest": {
54+
"description": "Label for UserRole.guest"
55+
},
56+
"userRoleUnknown": "Unknown",
57+
"@userRoleUnknown": {
58+
"description": "Label for UserRole.unknown"
59+
}
60+
}

lib/l10n/app_ja.arb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"chooseAccountPageTitle": "アカウントを選択",
3+
"chooseAccountButtonAddAnAccount": "新しいアカウントを追加",
4+
"profileButtonSendDirectMessage": "ダイレクトメッセージを送信",
5+
"cameraAccessDeniedTitle": "権限が必要です",
6+
"cameraAccessDeniedMessage": "画像をアップロードするには、「設定」で Zulip に追加の権限を許可してください。",
7+
"cameraAccessDeniedButtonText": "設定を開く",
8+
"subscribedToNStreams": "{num, plural, other{{num}つのストリームをフォローしています}}",
9+
"userRoleOwner": "オーナー",
10+
"userRoleAdministrator": "管理者",
11+
"userRoleModerator": "モデレータ",
12+
"userRoleMember": "メンバー",
13+
"userRoleGuest": "ゲスト",
14+
"userRoleUnknown": "不明"
15+
}

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)