Skip to content

Commit

Permalink
Release 1.1.0 and update demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenenyu committed Sep 14, 2023
1 parent 7f8e00b commit f7a25be
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.1.0] - 2023/09/14.

* Sync with flutter `3.13.4`.
* Ensure that the order of method parameters is consistent with arb.

## [1.0.1] - 2023/09/05.

* Fix executable `flutterl10n`.
Expand Down
12 changes: 9 additions & 3 deletions example/lib/generated/l10n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ abstract class S {
/// **'Hello World!'**
String get helloWorld;

/// A message with a single parameter
/// No description provided for @hello.
///
/// In en, this message translates to:
/// **'Hello {userName}'**
String hello(String userName);
/// **'Hello {yourName}, i\'m {myName}'**
String hello(Object yourName, Object myName);

/// Message with attributes
///
/// In en, this message translates to:
/// **'Hello {yourName},i\'m {myName}'**
String helloWithAttrs(String myName, String yourName);

/// A plural message
///
Expand Down
9 changes: 7 additions & 2 deletions example/lib/generated/l10n_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ class SEn extends S {
String get helloWorld => 'Hello World!';

@override
String hello(String userName) {
return 'Hello $userName';
String hello(Object yourName, Object myName) {
return 'Hello $yourName, i\'m $myName';
}

@override
String helloWithAttrs(String myName, String yourName) {
return 'Hello $yourName,i\'m $myName';
}

@override
Expand Down
9 changes: 7 additions & 2 deletions example/lib/generated/l10n_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ class SZh extends S {
String get helloWorld => '你好,世界!';

@override
String hello(String userName) {
return '你好 $userName';
String hello(Object yourName, Object myName) {
return '你好$yourName,我是$myName';
}

@override
String helloWithAttrs(String myName, String yourName) {
return '你好$yourName,我是$myName';
}

@override
Expand Down
15 changes: 9 additions & 6 deletions example/lib/l10n/l10n_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
},
"hello": "Hello {userName}",
"@hello": {
"description": "A message with a single parameter",
"hello": "Hello {yourName}, i'm {myName}",
"helloWithAttrs": "Hello {yourName},i'm {myName}",
"@helloWithAttrs": {
"description": "Message with attributes",
"placeholders": {
"userName": {
"type": "String",
"example": "Bob"
"myName": {
"type": "String"
},
"yourName": {
"type": "String"
}
}
},
Expand Down
15 changes: 9 additions & 6 deletions example/lib/l10n/l10n_zh.arb
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"@@locale": "zh",
"helloWorld": "你好,世界!",
"hello": "你好 {userName}",
"@hello": {
"description": "带有一个参数的消息",
"hello": "你好{yourName},我是{myName}",
"helloWithAttrs": "你好{yourName},我是{myName}",
"@helloWithAttrs": {
"description": "带属性的消息",
"placeholders": {
"userName": {
"type": "String",
"example": "老王"
"myName": {
"type": "String"
},
"yourName": {
"type": "String"
}
}
},
Expand Down
10 changes: 7 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class _MyHomePageState extends State<MyHomePage> {
if (r == true) {
print('changed to ${_locale?.toString()}');
setState(() {}); // first trigger S.delegate.load(_locale)
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Future.delayed(const Duration(seconds: 1), () {
setState(() {}); // then trigger rebuild to update S.current
});
}
Expand Down Expand Up @@ -116,8 +116,12 @@ class _MyHomePageState extends State<MyHomePage> {
subtitle: Text(SubS.current.helloWorld),
),
ListTile(
title: const Text("S.current.hello('Flutter')"),
subtitle: Text(S.current.hello('Flutter')),
title: const Text("S.current.hello('Flutter', 'Dart')"),
subtitle: Text(S.current.hello('Flutter', 'Dart')),
),
ListTile(
title: const Text("S.current.helloWithAttrs('Flutter', 'Dart')"),
subtitle: Text(S.current.helloWithAttrs('Flutter', 'Dart')),
),
ListTile(
title: const Text("S.current.nPandas(0)"),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_l10n
description: A dart library that generates Flutter localization code from ARB file.
homepage: https://github.com/chenenyu/flutter_l10n
version: 1.0.1
version: 1.1.0
topics:
- localization
- internationalization
Expand Down

0 comments on commit f7a25be

Please sign in to comment.