Skip to content

Commit

Permalink
chore(deps): update sealed_currencies to v1.4.0 (#151)
Browse files Browse the repository at this point in the history
* chore(deps): update dependencies

* fix: sync with changes from languages v1.4.0

* test(model): add international name getter test fiat currency model

* docs: provide changelog and update readme for v1.4.0

* fix(docs): proper replace regexp

* chore: remove codecov token reference from workflow files

* chore: move codecov token reference to env in the job definition

* ci: add codecov token as a required secret in dart packages

* fix(ci): provide codecov token to the languages in the flutter package workflow
  • Loading branch information
tsinis authored Apr 12, 2024
1 parent 87cc24f commit da959ba
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 34 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/dart_package_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
package_name:
required: true
type: string
secrets:
CODECOV_TOKEN:
required: true

jobs:
verify-dart-package:
Expand Down Expand Up @@ -86,13 +89,11 @@ jobs:
min_coverage: 90

- name: 💯 Upload coverage
uses: codecov/codecov-action@v3.1.6
uses: codecov/codecov-action@v4.2.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ env.relative_path }}/coverage/lcov.info
flags: ${{ inputs.package_name }}
name: ${{ inputs.package_name }}
token: ${{ secrets.CODECOV_TOKEN }}
override_branch: ${{ github.base_ref }}
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
verbose: true
11 changes: 6 additions & 5 deletions .github/workflows/flutter_package_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
package_name:
required: true
type: string
secrets:
CODECOV_TOKEN:
required: true

jobs:
verify-flutter-package:
Expand Down Expand Up @@ -86,13 +89,11 @@ jobs:
min_coverage: 90

- name: 💯 Upload coverage
uses: codecov/codecov-action@v3.1.6
uses: codecov/codecov-action@v4.2.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ env.relative_path }}/coverage/lcov.info
flags: ${{ inputs.package_name }}
name: ${{ inputs.package_name }}
token: ${{ secrets.CODECOV_TOKEN }}
override_branch: ${{ github.base_ref }}
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
verbose: true
4 changes: 3 additions & 1 deletion .github/workflows/sealed_currencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ jobs:
verify-sealed-currencies:
uses: ./.github/workflows/dart_package_workflow.yaml
with:
package_name: sealed_currencies
package_name: sealed_currencies
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/sealed_languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ jobs:
verify-sealed-languages:
uses: ./.github/workflows/dart_package_workflow.yaml
with:
package_name: sealed_languages
package_name: sealed_languages
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Copyright (c) Saša Stamenković <umpirsky@gmail.com>
Copyright (c) 2004-present Fabien Potencier
Copyright (c) 2005 Tobias Lutke
Copyright (c) 2008 Phusion
Copyright (c) 2023 Shane Emmons
Copyright (c) 2024 Shane Emmons
Copyright (c) 2017-present B. Martin
Copyright (c) 2023 Roman Cinis
Copyright (c) 2024 Roman Cinis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 33 additions & 0 deletions packages/sealed_currencies/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
## 1.4.0

NEW FEATURES

- 🦾 Language translations now also support all `GlobalMaterialLocalization` + `GlobalCupertinoLocalizations` locales.
- Added new `internationalName` getter in `IsoStandardized` interface, representing the international name of the ISO object.
- Added new `UpperCaseMap` class, that `UpperCaseIsoMap` extends, a simple version of `UpperCaseIsoMap` without key length checks and `IsoStandardized` values requirement.
- Added new `BasicLocale` class, that `TranslatedName` extends. Representing a type-safe world locale (language, country/region code and script).
- Added new `commonNamesCacheMap` method for all ISO based sealed classes collections, which allows to create a cache map of common names translations for the given `BasicLocale`.

BREAKING CHANGES

Because of the `BasicLocale` changes (described above), `translation()` and `maybeTranslation()` methods on the `Translated` classes now require `BasicLocale` input. If you are not using those methods directly, then you don't need to change anything, otherwise you will need to do small adjustment - wrap the content of those methods with a `BasicLocale`.

Before:

```dart
print(iso?.maybeTranslation(LangPor()));
```

After:

```dart
print(iso?.maybeTranslation(BasicLocale(LangPor())));
```

Or just:

1. Enable **Regular Expressions** in your IDE's **Find and Replace** panel.
2. In the **Find** field, enter the regex: `(translation\()(.*)(\))`
3. In the **Replace** field, enter: `$1BasicLocale($2)$3`
4. Execute the replace operation.

## 1.3.1

NEW FEATURES
Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_currencies/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright (c) Saša Stamenković <umpirsky@gmail.com>
Copyright (c) 2004-present Fabien Potencier
Copyright (c) 2005 Tobias Lutke
Copyright (c) 2008 Phusion
Copyright (c) 2023 Shane Emmons
Copyright (c) 2024 Shane Emmons
Copyright (c) 2024 Roman Cinis

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
6 changes: 3 additions & 3 deletions packages/sealed_currencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Use `FiatCurrency` class to get information about currencies. Either construct a
// Prints German translations of all available regular currencies.
for (final currency in FiatCurrency.list) {
print(
"""German name of ${currency.name}: ${currency.maybeTranslation(const LangDeu())?.name}""",
"""German name of ${currency.name}: ${currency.maybeTranslation(const BasicLocale(LangDeu()))?.name}""",
);
}
```
Expand All @@ -103,13 +103,13 @@ For more usage examples, please see the `/example` folder.
- **No 3rd-party dependencies**: This package has no third-party dependencies, ensuring that you won't have any issues or conflicts with other dependencies (no even `meta` here, because of that).
- **Rich data**: This package offers far more data than any other package + tons of translations (all [GlobalMaterialLocalizations](https://api.flutter.dev/flutter/flutter_localizations/GlobalMaterialLocalizations-class.html) and [GlobalCupertinoLocalizations](https://api.flutter.dev/flutter/flutter_localizations/GlobalCupertinoLocalizations-class.html) locales and more).
- **Type-safe**: The contracts and types in this package are very strong, ensuring that your code is strongly typed and well-defined.
- **High code coverage**: The code in this package has 100% code coverage, with more than 850 (+1500 in underling packages) tests, providing confidence in its reliability and stability.
- **High code coverage**: The code in this package has 100% code coverage, with more than 583 (+1533 in underling packages) tests, providing confidence in its reliability and stability.
- **Industry adopted**: This package is actively used in production by numerous European companies, ensuring its efficacy and robustness in real-world scenarios.
- **MIT License**: This package and sources are released under the MIT license, which is a permissive license that allows users to use, modify, and distribute the code with minimal restrictions. The MIT license is considered better than most other open-source licenses because it provides flexibility and allows users to incorporate the code into their projects without worrying about legal implications.

### Additional information

If you like this package, please give it a star or like. For more information on using this package, check out the API documentation. PRs or ideas are always welcome.
If you like this package, please give it a star or like. For more information on using this package, check out the API documentation. **PRs or ideas are always welcome**.
If you have any issues or suggestions for the package, please file them in the GitHub repository.

### References, credits and sources
Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_currencies/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void main() {
// Prints German translations of all available regular currencies.
for (final currency in FiatCurrency.list) {
print(
"""German name of ${currency.name}: ${currency.maybeTranslation(const LangDeu())?.name}""",
"""German name of ${currency.name}: ${currency.maybeTranslation(const BasicLocale(LangDeu()))?.name}""",
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ class FiatCurrency extends Currency
@override
String get codeOther => codeNumeric;

@override
String get internationalName => name;

/// Returns a string representation of this instance.
@override
String toString({bool short = true}) => short
Expand Down
4 changes: 2 additions & 2 deletions packages/sealed_currencies/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.3.1
version: 1.4.0
name: sealed_currencies
description: Provides data for world currencies in the form of sealed classes.
maintainer: Roman Cinis
Expand All @@ -21,7 +21,7 @@ environment:
sdk: ^3.0.0

dependencies:
sealed_languages: ^1.3.1
sealed_languages: ^1.4.0

dev_dependencies:
_sealed_world_tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import "package:_sealed_world_tests/sealed_world_tests.dart";
import "package:sealed_currencies/currency_translations.dart";
import "package:sealed_currencies/src/helpers/fiat_currency/fiat_currency_json.dart";
import "package:sealed_currencies/src/model/currency/currency.dart";
import "package:sealed_languages/sealed_languages.dart";
import "package:sealed_currencies/sealed_currencies.dart";
import "package:test/test.dart";

class _FiatCurrencyTest extends FiatCurrency {
Expand Down Expand Up @@ -47,6 +45,7 @@ void main() => group("$FiatCurrency", () {
expect(element.codeNumeric, isA<String>());
expect(element.codeNumeric, isNotEmpty);
expect(element.codeOther, element.codeNumeric);
expect(element.internationalName, element.name);
expect(element.namesNative, isA<List<String>>());
expect(element.namesNative, isNotEmpty);
if (element.alternateSymbols != null) {
Expand Down Expand Up @@ -733,18 +732,22 @@ void main() => group("$FiatCurrency", () {
group("translations", () {
test("translation should always provide at least eng translation", () {
const abkhazia = LangAbk();
const nonExistCode = "";
const nonExistCode = "000";
var count = 0;
for (final value in FiatCurrency.list) {
final maybeMissing = value.maybeTranslation(
abkhazia,
countryCode: nonExistCode,
const BasicLocale(
abkhazia,
countryCode: nonExistCode,
),
useLanguageFallback: false,
);
if (maybeMissing != null) continue;
count++;
expect(
value.translation(abkhazia, countryCode: nonExistCode),
value.translation(
const BasicLocale(abkhazia, countryCode: nonExistCode),
),
isNotNull,
);
}
Expand All @@ -758,7 +761,8 @@ void main() => group("$FiatCurrency", () {

for (final l10n in NaturalLanguage.list) {
for (final value in FiatCurrency.list) {
final hasTranslationForValue = value.maybeTranslation(l10n);
final hasTranslationForValue =
value.maybeTranslation(BasicLocale(l10n));
if (hasTranslationForValue != null) map[value] = map[value]! + 1;
}
}
Expand All @@ -777,8 +781,8 @@ void main() => group("$FiatCurrency", () {

for (final l10n in NaturalLanguage.list) {
for (final value in FiatCurrency.list) {
final hasTranslationForValue = value.maybeTranslation(l10n);
if (hasTranslationForValue != null) {
final translation = value.maybeTranslation(BasicLocale(l10n));
if (translation != null) {
map[l10n] = map[l10n]! + 1;
} else {
missing[l10n] = {...?missing[l10n], value};
Expand Down Expand Up @@ -808,11 +812,34 @@ void main() => group("$FiatCurrency", () {
for (final l10n in kSealedCurrenciesSupportedLanguages) {
if (l10n == const LangEng()) continue;
expect(
currency.translation(l10n),
isNot(currency.translation(const LangEng())),
currency.translation(BasicLocale(l10n)),
isNot(currency.translation(const BasicLocale(LangEng()))),
);
}
}
});

group("commonNamesCacheMap", () {
performanceTest(
"languages in supported list should have all translations",
() {
for (final language in kSealedCurrenciesSupportedLanguages) {
final cache = FiatCurrency.list.commonNamesCacheMap(
BasicLocale(language, script: language.scripts.first),
);
expect(cache.length, FiatCurrency.list.length);
}
},
);

performanceTest(
"""some languages should have at least 2 translations of it's own name""",
() {
final cache = FiatCurrency.list
.commonNamesCacheMap(const BasicLocale(LangKal()));
expect(cache.length, 2);
},
);
});
});
});
2 changes: 1 addition & 1 deletion packages/sealed_languages/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Or just:

1. Enable **Regular Expressions** in your IDE's **Find and Replace** panel.
2. In the **Find** field, enter the regex: `(translation\()(.*)(\))`
3. In the **Replace** field, enter: `$1const BasicLocale($2)$3`
3. In the **Replace** field, enter: `$1BasicLocale($2)$3`
4. Execute the replace operation.

## 1.3.1
Expand Down

0 comments on commit da959ba

Please sign in to comment.