diff --git a/CHANGELOG.md b/CHANGELOG.md index 25d0ae2..42ce77f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ +### 2.1.0 + +* Added `localeName` +* Bumped minimum Dart SDK version to 1.24.0-dev.0.0 + ### 2.0.0 + * Added `stdinSupportsAnsi` and `stdinSupportsAnsi` * Removed `ansiSupported` diff --git a/lib/src/interface/local_platform.dart b/lib/src/interface/local_platform.dart index c90256a..27c1871 100644 --- a/lib/src/interface/local_platform.dart +++ b/lib/src/interface/local_platform.dart @@ -52,4 +52,7 @@ class LocalPlatform extends Platform { @override bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes; + + @override + String get localeName => io.Platform.localeName; } diff --git a/lib/src/interface/platform.dart b/lib/src/interface/platform.dart index c750108..1ebc5a9 100644 --- a/lib/src/interface/platform.dart +++ b/lib/src/interface/platform.dart @@ -120,6 +120,9 @@ abstract class Platform { /// When stdout is connected to a terminal, whether ANSI codes are supported. bool get stdoutSupportsAnsi; + /// Get the name of the current locale. + String get localeName; + /// Returns a JSON-encoded representation of this platform. String toJson() { return const JsonEncoder.withIndent(' ').convert({ @@ -137,6 +140,7 @@ abstract class Platform { 'version': version, 'stdinSupportsAnsi': stdinSupportsAnsi, 'stdoutSupportsAnsi': stdoutSupportsAnsi, + 'localeName': localeName, }); } } diff --git a/lib/src/testing/fake_platform.dart b/lib/src/testing/fake_platform.dart index 16b8092..062930d 100644 --- a/lib/src/testing/fake_platform.dart +++ b/lib/src/testing/fake_platform.dart @@ -27,6 +27,7 @@ class FakePlatform extends Platform { this.version, this.stdinSupportsAnsi, this.stdoutSupportsAnsi, + this.localeName, }); /// Creates a new [FakePlatform] with properties whose initial values mirror @@ -46,7 +47,8 @@ class FakePlatform extends Platform { packageConfig = platform.packageConfig, version = platform.version, stdinSupportsAnsi = platform.stdinSupportsAnsi, - stdoutSupportsAnsi = platform.stdoutSupportsAnsi; + stdoutSupportsAnsi = platform.stdoutSupportsAnsi, + localeName = platform.localeName; /// Creates a new [FakePlatform] with properties extracted from the encoded /// JSON string. @@ -70,6 +72,7 @@ class FakePlatform extends Platform { version: map['version'], stdinSupportsAnsi: map['stdinSupportsAnsi'], stdoutSupportsAnsi: map['stdoutSupportsAnsi'], + localeName: map['localeName'], ); } @@ -114,4 +117,7 @@ class FakePlatform extends Platform { @override bool stdoutSupportsAnsi; + + @override + String localeName; } diff --git a/pubspec.yaml b/pubspec.yaml index ab7c8e9..591da6f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: platform -version: 2.0.0 +version: 2.1.0 authors: - Todd Volkert description: A pluggable, mockable platform abstraction for Dart. @@ -9,4 +9,4 @@ dev_dependencies: test: ^0.12.10 environment: - sdk: '>=1.23.0-dev.10.0 <2.0.0' + sdk: '>=1.24.0-dev.0.0 <2.0.0' diff --git a/test/fake_platform_test.dart b/test/fake_platform_test.dart index c294dd9..1fa7e8f 100644 --- a/test/fake_platform_test.dart +++ b/test/fake_platform_test.dart @@ -20,6 +20,7 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { expect(actual.packageRoot, expected.packageRoot); expect(actual.packageConfig, expected.packageConfig); expect(actual.version, expected.version); + expect(actual.localeName, expected.localeName); } void main() { @@ -75,6 +76,7 @@ void main() { expect(fake.packageRoot, null); expect(fake.packageConfig, null); expect(fake.version, '1.22.0'); + expect(fake.localeName, 'de/de'); }); test('fromJsonToJson', () { diff --git a/test/platform.json b/test/platform.json index df772c6..a39381c 100644 --- a/test/platform.json +++ b/test/platform.json @@ -15,5 +15,6 @@ ], "packageRoot": null, "packageConfig": null, - "version": "1.22.0" + "version": "1.22.0", + "localeName": "de/de" } \ No newline at end of file