diff --git a/pkgs/messages/LICENSE b/pkgs/messages/LICENSE new file mode 100644 index 00000000..4fd5739c --- /dev/null +++ b/pkgs/messages/LICENSE @@ -0,0 +1,27 @@ +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/messages/lib/src/message.dart b/pkgs/messages/lib/src/message.dart index df26babb..22ab8667 100644 --- a/pkgs/messages/lib/src/message.dart +++ b/pkgs/messages/lib/src/message.dart @@ -46,7 +46,7 @@ final class StringMessage extends Message { /// Maps argument indices to their position in the string, where they are to /// be inserted. /// - /// This list is expected to be sorted by [stringIndex] + /// This list is expected to be sorted by `argPositions.stringIndex` final List<({int stringIndex, int argIndex})> argPositions; StringMessage(this.value, {this.argPositions = const [], String? id}) diff --git a/pkgs/messages/lib/src/message_list_json.dart b/pkgs/messages/lib/src/message_list_json.dart index 7e93c920..dd67e391 100644 --- a/pkgs/messages/lib/src/message_list_json.dart +++ b/pkgs/messages/lib/src/message_list_json.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:messages_deserializer/messages_deserializer_json.dart'; +import 'package:messages_deserializer/messages_deserializer.dart'; import 'intl_object.dart'; import 'message_format.dart'; diff --git a/pkgs/messages/pubspec.yaml b/pkgs/messages/pubspec.yaml index 36c3b20b..f286c847 100644 --- a/pkgs/messages/pubspec.yaml +++ b/pkgs/messages/pubspec.yaml @@ -1,7 +1,6 @@ name: messages description: A lightweight modular library for localization (l10n) functionality. version: 0.1.0 -publish_to: none repository: https://github.com/dart-lang/i18n/tree/main/pkgs/messages environment: @@ -13,6 +12,5 @@ dependencies: messages_deserializer: ^0.1.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 - lints: ^2.0.0 + dart_flutter_team_lints: ^2.1.1 test: ^1.16.0 diff --git a/pkgs/messages_builder/LICENSE b/pkgs/messages_builder/LICENSE new file mode 100644 index 00000000..4fd5739c --- /dev/null +++ b/pkgs/messages_builder/LICENSE @@ -0,0 +1,27 @@ +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/messages_builder/lib/builder.dart b/pkgs/messages_builder/lib/builder.dart index 7b64d26e..f18435a3 100644 --- a/pkgs/messages_builder/lib/builder.dart +++ b/pkgs/messages_builder/lib/builder.dart @@ -175,7 +175,7 @@ class BuildStepGenerator { /// unpacked at runtime so that the messages can be read from it. /// /// Returns the list of indices of the messages which are visible to the user. - Future writeDataFile(MessagesWithMetadata messages) async { + Future writeDataFile(MessagesWithMetadata messages) async { final serialization = serializer.serialize( messages.hash, messages.locale, diff --git a/pkgs/messages_builder/pubspec.yaml b/pkgs/messages_builder/pubspec.yaml index 9eb4bba7..a5bfc6d8 100644 --- a/pkgs/messages_builder/pubspec.yaml +++ b/pkgs/messages_builder/pubspec.yaml @@ -1,7 +1,6 @@ name: messages_builder description: Build the messages for consumption by package:messages version: 0.1.0 -publish_to: none repository: https://github.com/dart-lang/i18n/pkgs/messages_builder environment: @@ -23,7 +22,6 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 build_web_compilers: ^4.0.5 - dart_flutter_team_lints: ^1.0.0 - lints: ^2.0.0 + dart_flutter_team_lints: ^2.1.1 messages_deserializer: ^0.1.0 test: ^1.16.0 diff --git a/pkgs/messages_builder/test/web_deserializer_native_test.dart b/pkgs/messages_builder/test/web_deserializer_native_test.dart index c35357b7..3454153f 100644 --- a/pkgs/messages_builder/test/web_deserializer_native_test.dart +++ b/pkgs/messages_builder/test/web_deserializer_native_test.dart @@ -9,7 +9,7 @@ import 'package:messages/messages.dart'; import 'package:messages/package_intl_object.dart'; import 'package:messages_builder/arb_parser.dart'; import 'package:messages_builder/message_with_metadata.dart'; -import 'package:messages_deserializer/messages_deserializer_json.dart'; +import 'package:messages_deserializer/messages_deserializer.dart'; import 'package:messages_serializer/messages_serializer.dart'; import 'package:test/test.dart'; diff --git a/pkgs/messages_deserializer/LICENSE b/pkgs/messages_deserializer/LICENSE new file mode 100644 index 00000000..4fd5739c --- /dev/null +++ b/pkgs/messages_deserializer/LICENSE @@ -0,0 +1,27 @@ +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/messages_deserializer/lib/messages_deserializer_json.dart b/pkgs/messages_deserializer/lib/messages_deserializer.dart similarity index 100% rename from pkgs/messages_deserializer/lib/messages_deserializer_json.dart rename to pkgs/messages_deserializer/lib/messages_deserializer.dart diff --git a/pkgs/messages_deserializer/pubspec.yaml b/pkgs/messages_deserializer/pubspec.yaml index 41d189cc..9493a8c7 100644 --- a/pkgs/messages_deserializer/pubspec.yaml +++ b/pkgs/messages_deserializer/pubspec.yaml @@ -1,7 +1,6 @@ name: messages_deserializer description: Deserialization of messages for package:messages. version: 0.1.0 -publish_to: none repository: https://github.com/dart-lang/i18n/tree/main/pkgs/messages_deserializer environment: @@ -14,5 +13,4 @@ dependencies: dev_dependencies: dart_flutter_team_lints: ^2.0.0 - lints: ^2.0.0 test: ^1.21.0 diff --git a/pkgs/messages_serializer/LICENSE b/pkgs/messages_serializer/LICENSE new file mode 100644 index 00000000..4fd5739c --- /dev/null +++ b/pkgs/messages_serializer/LICENSE @@ -0,0 +1,27 @@ +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/messages_serializer/lib/src/serializer_json.dart b/pkgs/messages_serializer/lib/src/serializer_json.dart index 8aca238d..2b468af5 100644 --- a/pkgs/messages_serializer/lib/src/serializer_json.dart +++ b/pkgs/messages_serializer/lib/src/serializer_json.dart @@ -85,7 +85,7 @@ class JsonSerializer extends Serializer { if ((message.id == null || isVisible == false) && !containsArgs) { return message.value; } - final m = []; + final m = []; addId(message, m, isVisible); m.add(message.value); if (containsArgs) { @@ -106,7 +106,7 @@ class JsonSerializer extends Serializer { /// * Map\ | the cases: /// * MapEntry\ | a case mapped to the message it represents List encodeSelect(SelectMessage message, bool isVisible) { - final m = []; + final m = []; m.add(SelectMessage.type); addId(message, m, isVisible); m.add(message.argIndex); @@ -129,12 +129,12 @@ class JsonSerializer extends Serializer { /// * int | the case index as encoded by the constants in `Plural` /// * int | the message index of the case List encodePlural(PluralMessage message, bool isVisible) { - final m = []; + final m = []; m.add(PluralMessage.type); addId(message, m, isVisible); m.add(message.argIndex); m.add(encodeMessage(message.other)); - final caseIndices = []; + final caseIndices = []; if (message.few != null) { caseIndices.add(Plural.few); caseIndices.add(encodeMessage(message.few!)); @@ -178,7 +178,7 @@ class JsonSerializer extends Serializer { /// * List\ | the submessage IDs /// * int | the index of the submessage List encodeCombined(CombinedMessage message, bool isVisible) { - final m = []; + final m = []; m.add(CombinedMessage.type); addId(message, m, isVisible); for (var submessage in message.messages) { @@ -197,12 +197,12 @@ class JsonSerializer extends Serializer { /// * int | the case index as encoded by the constants in `Gender` /// * int | the message index of the case List encodeGender(GenderMessage message, bool isVisible) { - final m = []; + final m = []; m.add(GenderMessage.type); addId(message, m, isVisible); m.add(message.argIndex); m.add(encodeMessage(message.other)); - final caseIndices = []; + final caseIndices = []; if (message.female != null) { caseIndices.add(Gender.female); caseIndices.add(encodeMessage(message.female!)); diff --git a/pkgs/messages_serializer/pubspec.yaml b/pkgs/messages_serializer/pubspec.yaml index a2927960..ebd83e23 100644 --- a/pkgs/messages_serializer/pubspec.yaml +++ b/pkgs/messages_serializer/pubspec.yaml @@ -1,7 +1,6 @@ name: messages_serializer description: Serialization of messages for package:messages. version: 0.1.0 -publish_to: none repository: https://github.com/dart-lang/i18n/tree/main/pkgs/messages_serializer environment: @@ -12,7 +11,6 @@ dependencies: messages: ^0.1.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 - lints: ^2.0.0 + dart_flutter_team_lints: ^2.1.1 messages_deserializer: ^0.1.0 test: ^1.21.0 diff --git a/pkgs/messages_serializer/test/messages_serializer_test.dart b/pkgs/messages_serializer/test/messages_serializer_test.dart index 562d7546..ec9ba148 100644 --- a/pkgs/messages_serializer/test/messages_serializer_test.dart +++ b/pkgs/messages_serializer/test/messages_serializer_test.dart @@ -6,7 +6,7 @@ import 'dart:math'; import 'package:messages/messages_json.dart'; import 'package:messages/package_intl_object.dart'; -import 'package:messages_deserializer/messages_deserializer_json.dart'; +import 'package:messages_deserializer/messages_deserializer.dart'; import 'package:messages_serializer/messages_serializer.dart'; import 'package:test/test.dart'; diff --git a/pkgs/messages_shrinker/LICENSE b/pkgs/messages_shrinker/LICENSE new file mode 100644 index 00000000..ac900319 --- /dev/null +++ b/pkgs/messages_shrinker/LICENSE @@ -0,0 +1,27 @@ +Copyright 2023, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/pkgs/messages_shrinker/lib/messages_shrinker.dart b/pkgs/messages_shrinker/lib/messages_shrinker.dart index 5ae46b18..3c353c1a 100644 --- a/pkgs/messages_shrinker/lib/messages_shrinker.dart +++ b/pkgs/messages_shrinker/lib/messages_shrinker.dart @@ -6,7 +6,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:messages/package_intl_object.dart'; -import 'package:messages_deserializer/messages_deserializer_json.dart'; +import 'package:messages_deserializer/messages_deserializer.dart'; import 'package:messages_serializer/messages_serializer.dart'; class MessageShrinker { diff --git a/pkgs/messages_shrinker/pubspec.yaml b/pkgs/messages_shrinker/pubspec.yaml index 9c0edda0..d9542f03 100644 --- a/pkgs/messages_shrinker/pubspec.yaml +++ b/pkgs/messages_shrinker/pubspec.yaml @@ -1,7 +1,6 @@ name: messages_shrinker description: A starting point for Dart libraries or applications. version: 0.1.0 -publish_to: none repository: https://github.com/dart-lang/i18n/pkgs/messages_shrinker environment: @@ -19,5 +18,4 @@ dependencies: dev_dependencies: dart_flutter_team_lints: ^2.0.0 - lints: ^2.0.0 test: ^1.21.0 diff --git a/pkgs/messages_shrinker/test/message_shrinker_test.dart b/pkgs/messages_shrinker/test/message_shrinker_test.dart index 66902c19..52737bf8 100644 --- a/pkgs/messages_shrinker/test/message_shrinker_test.dart +++ b/pkgs/messages_shrinker/test/message_shrinker_test.dart @@ -2,13 +2,16 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'dart:convert'; import 'dart:io'; import 'package:build/build.dart'; import 'package:messages/package_intl_object.dart'; import 'package:messages_builder/arb_parser.dart'; -import 'package:messages_deserializer/messages_deserializer_json.dart'; +import 'package:messages_deserializer/messages_deserializer.dart'; import 'package:messages_serializer/messages_serializer.dart'; import 'package:messages_shrinker/messages_shrinker.dart'; import 'package:test/test.dart'; @@ -37,23 +40,25 @@ void main() { final generateStringAtIndex = deserialize.generateStringAtIndex(1, args); expect(generateStringAtIndex, getMessage(messageIndex, args)); }); + test( + 'Shrink a json with const from file', + () { + final outputFile = '/tmp/shrunkFile.json'; + MessageShrinker().shrink( + dataFile, + 'test/const_files.json', + outputFile, + ); - test('Shrink a json with const from file', () { - final outputFile = '/tmp/shrunkFile.json'; - MessageShrinker().shrink( - dataFile, - 'test/const_files.json', - outputFile, - ); - - final dataFileContentsShrunk = File(outputFile).readAsStringSync(); - expect(dataFileContentsShrunk.length, lessThan(dataFileContents.length)); - final deserialize = - JsonDeserializer(dataFileContentsShrunk).deserialize(intl); - final args = [2]; - final generateStringAtIndex = deserialize.generateStringAtIndex(1, args); - expect(generateStringAtIndex, getMessage(1, args)); - }); + final dataFileContentsShrunk = File(outputFile).readAsStringSync(); + expect(dataFileContentsShrunk.length, lessThan(dataFileContents.length)); + final deserialize = + JsonDeserializer(dataFileContentsShrunk).deserialize(intl); + final args = [2]; + final generateStringAtIndex = deserialize.generateStringAtIndex(1, args); + expect(generateStringAtIndex, getMessage(1, args)); + }, + ); } String readArbFileToDataFile() {