Skip to content

Commit

Permalink
docs: update languages structure screenshot (#70)
Browse files Browse the repository at this point in the history
* docs: update structure screenshot

* feat: added material supported languages sealed constant

* feat: added iso standardized string extension

* test: tests for iso standardized string extension
  • Loading branch information
tsinis authored Oct 21, 2023
1 parent 2cc7c98 commit 9f4afd4
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 1 deletion.
Binary file modified packages/sealed_languages/doc/structure.webp
Binary file not shown.
89 changes: 88 additions & 1 deletion packages/sealed_languages/lib/language_translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export "src/translations/zha_language.l10n.dart";
export "src/translations/zho_language.l10n.dart";
export "src/translations/zul_language.l10n.dart";

// ignore_for_file: prefer-static-class

/// This is a comprehensive list of languages that ensure the availability of
/// translations for every language in the natural language list.
///
Expand All @@ -202,7 +204,6 @@ export "src/translations/zul_language.l10n.dart";
/// than 56 translations of it's name to other languages.
///
/// This a small (as for now) brother of [kMaterialSupportedLanguages](https://api.flutter.dev/flutter/flutter_localizations/kMaterialSupportedLanguages.html).
// ignore: prefer-static-class, to follow the naming convention of Flutter's SDK.
const kSealedLanguagesSupportedLanguages = [
LangPor(),
LangPol(),
Expand Down Expand Up @@ -260,3 +261,89 @@ const kSealedLanguagesSupportedLanguages = [
LangZho(),
LangLao(),
];

/// Sealed languages version of the `kMaterialSupportedLanguages` list.
///
/// Implementation of localized strings for the material widgets using
/// the `intl` package for date and time formatting.
/// Missing "FIL" (Filipino Pilipino) + "GSW" (Swiss German Alemannic Alsatian)
/// languages.
const kMaterialSupportedLanguagesSealed = [
LangAfr(),
LangAmh(),
LangAra(),
LangAsm(),
LangAze(),
LangBel(),
LangBul(),
LangBen(),
LangBos(),
LangCat(),
LangCes(),
LangCym(),
LangDan(),
LangDeu(),
LangEll(),
LangEng(),
LangSpa(),
LangEst(),
LangEus(),
LangFas(),
LangFin(),
LangFra(),
LangGlg(),
LangGuj(),
LangHeb(),
LangHin(),
LangHrv(),
LangHun(),
LangHye(),
LangInd(),
LangIsl(),
LangIta(),
LangJpn(),
LangKat(),
LangKaz(),
LangKhm(),
LangKan(),
LangKor(),
LangKir(),
LangLao(),
LangLit(),
LangLav(),
LangMkd(),
LangMal(),
LangMon(),
LangMar(),
LangMsa(),
LangMya(),
LangNob(),
LangNep(),
LangNld(),
LangNor(),
LangOri(),
LangPan(),
LangPol(),
LangPus(),
LangPor(),
LangRon(),
LangRus(),
LangSin(),
LangSlk(),
LangSlv(),
LangSqi(),
LangSrp(),
LangSwe(),
LangSwa(),
LangTam(),
LangTel(),
LangTha(),
LangTgl(),
LangTur(),
LangUkr(),
LangUrd(),
LangUzb(),
LangVie(),
LangZho(),
LangZul(),
];
1 change: 1 addition & 0 deletions packages/sealed_languages/lib/sealed_languages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ library sealed_languages;
export "src/data/natural_language_families.data.dart";
export "src/data/natural_languages.data.dart";
export "src/data/scripts.data.dart";
export "src/helpers/extensions/iso_standardized_string_extension.dart";
export "src/helpers/extensions/sealed_world_iterable_extension.dart";
export "src/helpers/extensions/sealed_world_json_string_extension.dart";
export "src/helpers/extensions/translated_extension.dart";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// Extension on [String] providing additional functionality
/// for ISO standardized strings.
extension IsoStandardizedStringExtension on String {
/// Checks if the string is a valid ISO code.
///
/// Returns `true` if the string matches strings that consist of Latin
/// characters (uppercase or lowercase) and have a length of 3 or more
/// characters, indicating that it is a valid ISO code.
/// Returns `false` otherwise.
///
/// In terms of this package, it means that it is a valid
/// ISO `code` (not `codeOther`).
bool get isIsoCode => RegExp(r"^[a-zA-Z]{3,}$").hasMatch(this);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import "package:sealed_languages/sealed_languages.dart";
import "package:test/test.dart";

void main() => group("IsoStandardizedStringExtension", () {
group("isIsoCode", () {
test("should return true for valid ISO codes", () {
expect("ENG".isIsoCode, isTrue);
expect("Latn".isIsoCode, isTrue);
expect("abc".isIsoCode, isTrue);
expect("xyz".isIsoCode, isTrue);
expect("AbC".isIsoCode, isTrue);
});

test("should return false for invalid ISO codes", () {
expect("A".isIsoCode, isFalse);
expect("AB".isIsoCode, isFalse);
expect("123".isIsoCode, isFalse);
expect("AB3".isIsoCode, isFalse);
expect("abc123".isIsoCode, isFalse);
expect("!@#".isIsoCode, isFalse);
});
});
});

0 comments on commit 9f4afd4

Please sign in to comment.