Skip to content

Commit

Permalink
feat!: sealed languages translations (#67)
Browse files Browse the repository at this point in the history
* feat(model): moved translated name and extension

* refactor: general refactoring in basic classes

* feat(cli): created data list generator for cli

* feat(cli): recreate natural langs data with cli

* refactor(cli): small lints fixes in cli

* feat(cli): created network utils

* feat(cli): added basic json utils

* feat(data): added scripts (iso-15924)

* feat(model): added script functional methods

* doc(model): added dartdoc for non-data script code

* docs(data): added dartdoc for script data

* feat(model): added scripts to natural language

* feat(helpers): improved extension methods and added new

* test: added unit tests for scripts

* feat(model): added script to the translated name

* refactor(cli): improve json and io utils

* feat(translations): added translations for natural langs

* refactor(cli): better library for exports

* feat(model): add translated interface and lang translations

* refactor: added basic translated extension

* fix(translations): provide proper base translations

* fix(lint): dart format .

* feat: added translation and maybe translation methods

* feat(l10n): added more translations for multiple langs

* docs: update reference and code length dartdoc

* docs: added and updated dartdoc for languages

* refactor: refactoring of exports/imports in the package

* refactor(cli): provided exports command to cli

* chore(deps): update example and dev dependencies

* style: rename *_translations.dart files to *.l10n.dart
  • Loading branch information
tsinis authored Oct 15, 2023
1 parent 47968ba commit 0d07dbe
Show file tree
Hide file tree
Showing 258 changed files with 43,813 additions and 1,419 deletions.
1 change: 1 addition & 0 deletions .github/workflows/config/spell-check/excludes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(?:(?i)LICENSE)
(?:^|/)data/
\.data.dart$
\.l10n.dart$
\.freezed.dart$
\.g.dart$
\.ico$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Indo
Svn
Svn
2 changes: 1 addition & 1 deletion .github/workflows/dart_package_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
uses: VeryGoodOpenSource/[email protected]
with:
path: ${{ env.relative_path }}/coverage/lcov.info
exclude: "**/*.g.dart **/*.data.dart"
exclude: "**/*.g.dart **/*.data.dart **/*.l10n.dart"
min_coverage: 90

- name: 💯 Upload coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flutter_package_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
uses: VeryGoodOpenSource/[email protected]
with:
path: ${{ env.relative_path }}/coverage/lcov.info
exclude: "**/*.g.dart **/*.data.dart"
exclude: "**/*.g.dart **/*.data.dart **/*.l10n.dart"
min_coverage: 90

- name: 💯 Upload coverage
Expand Down
14 changes: 12 additions & 2 deletions .vscode/sealed_world.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,21 @@
"source.sortMembers": "never"
}
},
"cSpell.words": ["Cinis", "cioc", "demonym", "demonyms", "gini"],
"cSpell.words": [
"Bhojpuri",
"Cinis",
"cioc",
"demonym",
"demonyms",
"devcontainers",
"gini",
"umpirsky"
],
"cSpell.useGitignore": true,
"cSpell.ignorePaths": [
".git", // Ignore the .git directory
"**/lib/**/*.data.dart",
"**/lib/**/*.l10n.dart",
"**/lib/**/*.g.dart",
"**/lib/**/*.freezed.dart",
"**/lib/**/*.select.dart",
Expand Down Expand Up @@ -259,7 +269,7 @@
},
{
"type": "shell",
"command": "lcov -r coverage/lcov.info '*/*.g.dart' '*/*.data.dart' -o coverage/lcov.info --ignore-errors unused",
"command": "lcov -r coverage/lcov.info '*/*.g.dart' '*/*.l10n.dart' '*/*.data.dart' -o coverage/lcov.info --ignore-errors unused",
"label": "Remove Generated Files from Coverage",
"presentation": {
"reveal": "never",
Expand Down
2 changes: 2 additions & 0 deletions packages/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ dart_code_metrics:
exclude:
- test/**
- lib/**/constants.dart
- "**/translations/**.l10n.dart"
- member-ordering:
order:
- constructors
Expand All @@ -96,6 +97,7 @@ dart_code_metrics:
- avoid-non-ascii-symbols:
exclude:
- "**/data/**.data.dart"
- "**/translations/**.l10n.dart"
- arguments-ordering:
child-last: true
- avoid-banned-imports: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO!: Move to languages.
// TODO: Remove.
/// Extension on [List] class to provide helper methods for working with lists.
extension SealedWorldListExtension<T extends Object> on List<T?> {
/// Returns a [String] representation of the list containing only the names of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import "../extensions/country_submodels/maps_extension.dart";
import "../extensions/country_submodels/postal_code_extension.dart";
import "../extensions/translated_name_extension.dart";

/// Extension methods for serializing and deserializing [WorldCountry] objects
/// to/from JSON like maps.
/// Extension on [WorldCountry] that provides methods for converting
/// [WorldCountry] objects to and from JSON maps.
extension WorldCountryJson on WorldCountry {
/// {@macro to_map_method}
Map<String, Object?> toMap() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_countries/lib/src/interfaces/named.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO! Move to languages.
// TODO: Remove.
/// An abstract interface class for objects that have a [String] name.
///
/// This interface provides a common structure for objects that have a name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "package:sealed_currencies/sealed_currencies.dart";
import "../helpers/extensions/translated_name_extension.dart";
import "../interfaces/named.dart";

// TODO! Move to languages.
// TODO: Remove.
/// A class representing a translated name of a country or region.
///
/// This class implements the [Named] interface and the
Expand Down
6 changes: 4 additions & 2 deletions packages/sealed_countries/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.6 # From Google
coverage: ^1.6.4 # From Google
dart_code_metrics: ^5.7.6 # Flutter Favorite
dart_code_metrics: # Flutter Favorite
git:
url: https://github.com/tsinis/dart-code-metrics
lints: ^2.1.1 # From Google
test: ^1.24.7 # From Google
test: ^1.24.8 # From Google
6 changes: 4 additions & 2 deletions packages/sealed_currencies/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.6 # From Google
coverage: ^1.6.4 # From Google
dart_code_metrics: ^5.7.6 # Flutter Favorite
dart_code_metrics: # Flutter Favorite
git:
url: https://github.com/tsinis/dart-code-metrics
lints: ^2.1.1 # From Google
test: ^1.24.7 # From Google
test: ^1.24.8 # From Google
27 changes: 18 additions & 9 deletions packages/sealed_languages/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
## 0.6.0
## 0.7.0

NEW FEATURES

- Added new sealed class - Scripts, comes from ISO 15924 standard.
- NaturalLanguage class now contains info about scripts (writing systems) and translations of language name to other languages.
- Added translation and maybeTranslation methods for Translated classes (NaturalLanguage).
- Refactored factory constructors for IsoStandardized classes - there is an optional parameter to provide custom list
- Added TranslatedName class for translations.
- Added new abstract interfaces: Named and Translated.

- feat(model): added new interfaces and typedefs
- feat(model): added copy with, to-json etc.
- fix(data): proper names native list for sindhi
## 0.6.0

NEW FEATURES:
NEW FEATURES

- Added new interfaces (IsoStandardized, JsonEncodable) and typedef (JsonMap) to the model.
- Added copyWith, toJson etc. to the NaturalLanguage class.
- Fixed the names native list for Sindhi in the data.

## 0.5.0

BREAKING CHANGES

- refactor(data)!: languages list is now sorted alphabetically by the (3 letter) code

OTHER

- refactor(model): factory constructors and static methods for data classes creation now implicitly trimming and comparing uppercase string inputs
- refactor(lints): fixing old ignores and new linter rules
- chore(deps): updates of dev_dependencies

BREAKING CHANGES:

- refactor(data)!: languages list is now sorted alphabetically by the (3 letter) code

## 0.2.2

- chore(deps): bump internal dev_dependencies versions
Expand Down
1 change: 1 addition & 0 deletions packages/sealed_languages/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2017-present B. Martin
Copyright (c) Saša Stamenković <[email protected]>
Copyright (c) 2023 Roman Cinis

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
26 changes: 26 additions & 0 deletions packages/sealed_languages/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ void main() {
final russian = NaturalLanguage.fromCodeShort("ru");
print("${russian.name}: ${russian.code}"); // Prints: "Russian: RUS".

/// Translations of the language name.
print(russian.translations.length); // Prints: 120.

final maybeCzech = NaturalLanguage.maybeFromValue(
"CZE",
where: (language) => language.bibliographicCode,
Expand All @@ -30,4 +33,27 @@ void main() {
print(maybeCzech?.maybeWhen(langCes: () => "Ahoj!", orElse: () => "Hey!"));

print(NaturalLanguage.list.length); // Prints: "184".

/// Translations:
// Prints Slovak translations of all available languages.
for (final language in NaturalLanguage.list) {
print(
"""Slovak name of ${language.name}: ${language.maybeTranslation(const LangSlk())?.name}""",
);
}

// Distinguishes country code in translations.
print(maybeCzech?.maybeTranslation(const LangPor())?.name); // Prints tcheco.
print(
maybeCzech?.maybeTranslation(const LangPor(), countryCode: "PT")?.name,
); // Prints "checo".

// Distinguishes script in translations.
print(maybeCzech?.maybeTranslation(const LangSrp())?.name); // Prints "чешки".
print(
maybeCzech
?.maybeTranslation(const LangSrp(), script: const ScriptLatn())
?.name, // Prints "češki".
);
}
Loading

0 comments on commit 0d07dbe

Please sign in to comment.