From af04f8547846f547ce07dd3c085992747293794c Mon Sep 17 00:00:00 2001 From: karolgeneral <167442610+karolgeneral@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:34:29 +0200 Subject: [PATCH] Feature/13 slang (#15) * integration of the slang library and transfer of strings to the translation file # Conflicts: # lib/barcodes_panel.dart * add slang to barcode panel * review fixes/13 * fixes review/13 * fixes review/13 * fixes review/13 * fixes review/13 * fixes review/13 * fixes review/13 * fixes review/13 --- analysis_options.yaml | 1 + lib/barcode_item.dart | 81 +++++---- lib/barcodes_page.dart | 5 +- lib/barcodes_panel.dart | 32 ++-- lib/i18n/strings-en.i18n.json | 24 +++ lib/i18n/strings-pl.i18n.json | 24 +++ lib/i18n/strings.g.dart | 308 ++++++++++++++++++++++++++++++++++ lib/i18n/strings.i18n.json | 24 +++ lib/main.dart | 11 +- pubspec.lock | 50 +++++- pubspec.yaml | 2 + 11 files changed, 507 insertions(+), 55 deletions(-) create mode 100644 lib/i18n/strings-en.i18n.json create mode 100644 lib/i18n/strings-pl.i18n.json create mode 100644 lib/i18n/strings.g.dart create mode 100644 lib/i18n/strings.i18n.json diff --git a/analysis_options.yaml b/analysis_options.yaml index 0d29021..82066d4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -26,3 +26,4 @@ linter: # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + \ No newline at end of file diff --git a/lib/barcode_item.dart b/lib/barcode_item.dart index 0996010..d941eed 100644 --- a/lib/barcode_item.dart +++ b/lib/barcode_item.dart @@ -1,4 +1,5 @@ import 'package:barcode_widget/barcode_widget.dart'; +import 'i18n/strings.g.dart'; class BarcodeItem { final String description; @@ -11,40 +12,48 @@ class BarcodeItem { required this.type, }); - static final List barcodes = [ - BarcodeItem( - description: "Firma nie zweryfikowana", - data: "5905499300707", - type: Barcode.ean13()), - BarcodeItem( - description: "Firma zweryfikowana z pełną punktacją", - data: "5907632637572", - type: Barcode.ean13()), - BarcodeItem( - description: "Firma zweryfikowana z niepełną punktacją", - data: "5900497025454", - type: Barcode.ean13()), - BarcodeItem( - description: "Kod wewnętrzny", data: "00000000", type: Barcode.ean8()), - BarcodeItem( - description: "Firma zarejestrowana poza Polską", - data: "8680861069075", - type: Barcode.ean13()), - BarcodeItem( - description: "Firma zarejerstrowana w ...", - data: "5090000000006", - type: Barcode.ean13()), - BarcodeItem( - description: "Marka własna Lidla", - data: "20982515", - type: Barcode.ean8()), - BarcodeItem( - description: "Przyjaciel Poli", - data: "5906395053018", - type: Barcode.ean13()), - BarcodeItem( - description: "Rozszerzony opis firmy", - data: "9771644705002", - type: Barcode.ean13()), - ]; + static List barcodes(Translations translations) { + return [ + BarcodeItem( + description: translations.barcodesDescription.companyNotVerified, + data: "5905499300707", + type: Barcode.ean13()), + BarcodeItem( + description: + translations.barcodesDescription.companyVerifiedWithFullScores, + data: "5907632637572", + type: Barcode.ean13()), + BarcodeItem( + description: translations + .barcodesDescription.companyVerifiedWithIncompleteScores, + data: "5900497025454", + type: Barcode.ean13()), + BarcodeItem( + description: translations.barcodesDescription.internalCode, + data: "00000000", + type: Barcode.ean8()), + BarcodeItem( + description: + translations.barcodesDescription.companyRegisteredOutsidePoland, + data: "8680861069075", + type: Barcode.ean13()), + BarcodeItem( + description: translations.barcodesDescription.companyRegisteredIn, + data: "5090000000006", + type: Barcode.ean13()), + BarcodeItem( + description: translations.barcodesDescription.lidlOwnBrand, + data: "20982515", + type: Barcode.ean8()), + BarcodeItem( + description: translations.barcodesDescription.polaFriend, + data: "5906395053018", + type: Barcode.ean13()), + BarcodeItem( + description: + translations.barcodesDescription.extendedCompanyDescription, + data: "9771644705002", + type: Barcode.ean13()), + ]; + } } diff --git a/lib/barcodes_page.dart b/lib/barcodes_page.dart index 2452c3f..34020ff 100644 --- a/lib/barcodes_page.dart +++ b/lib/barcodes_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'barcode_item.dart'; import 'barcodes_list_view.dart'; import 'barcodes_panel.dart'; +import 'i18n/strings.g.dart'; class BarcodesPage extends StatefulWidget { const BarcodesPage({ @@ -32,10 +33,10 @@ class BarcodesPageState extends State { } @override - Widget build(BuildContext context) { + Widget build(context) { return Scaffold( appBar: AppBar( - title: const Text('Lista Kodów Kreskowych'), + title: Text(Translations.of(context).barcodeList) ), body: Padding( padding: const EdgeInsets.all(8.0), diff --git a/lib/barcodes_panel.dart b/lib/barcodes_panel.dart index 1f1fcdc..55e6af6 100644 --- a/lib/barcodes_panel.dart +++ b/lib/barcodes_panel.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:barcode_widget/barcode_widget.dart'; import 'barcode_type.dart' as custom; +import 'i18n/strings.g.dart'; class BarcodesPanel extends StatefulWidget { const BarcodesPanel({ @@ -35,10 +36,13 @@ class BarcodesPanelState extends State { final data = _dataController.text; final barcodeType = _selectedBarcodeType; - setState(() { - _descriptionError = - description.isEmpty ? "Opis nie może być pusty" : null; - _dataError = data.isEmpty ? "Kod kreskowy nie może być pusty" : null; + setState(() { + final translations = Translations.of(context); + _descriptionError = description.isEmpty + ? translations.error.emptyDescription + : null; + _dataError = + data.isEmpty ? translations.error.emptyCode : null; if (_descriptionError == null && _dataError == null) { if (barcodeType.barcode.isValid(data)) { @@ -46,7 +50,7 @@ class BarcodesPanelState extends State { _descriptionController.clear(); _dataController.clear(); } else { - _dataError = "Nieprawidłowy kod kreskowy"; + _dataError = translations.error.invalidCode; } } }); @@ -79,15 +83,15 @@ class BarcodesPanelState extends State { ); } - Widget _dropdownField() { + Widget _dropdownField(BuildContext context) { return Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ DropdownButtonFormField( value: _selectedBarcodeType, - decoration: const InputDecoration( - labelText: "Typ kodu", + decoration: InputDecoration( + labelText: Translations.of(context).codeType, ), items: custom.BarcodeType.values.map((custom.BarcodeType type) { return DropdownMenuItem( @@ -103,7 +107,7 @@ class BarcodesPanelState extends State { }); }, ), - const SizedBox(height: Constants.errorHeight) + const SizedBox(height: Constants.errorHeight), ], ), ); @@ -118,17 +122,19 @@ class BarcodesPanelState extends State { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _textField(_descriptionController, "Opis", _descriptionError), + _textField(_descriptionController, + Translations.of(context).description, _descriptionError), const SizedBox(width: Constants.fieldSpacing), - _textField(_dataController, "Kod kreskowy", _dataError), + _textField( + _dataController, Translations.of(context).code, _dataError), const SizedBox(width: Constants.fieldSpacing), - _dropdownField(), + _dropdownField(context), const SizedBox(width: Constants.fieldSpacing), Padding( padding: const EdgeInsets.only(top: Constants.errorHeight), child: ElevatedButton( onPressed: _handleAddBarcode, - child: const Text('Dodaj kod kreskowy'), + child: Text(Translations.of(context).addCode), ), ), ], diff --git a/lib/i18n/strings-en.i18n.json b/lib/i18n/strings-en.i18n.json new file mode 100644 index 0000000..6110da1 --- /dev/null +++ b/lib/i18n/strings-en.i18n.json @@ -0,0 +1,24 @@ +{ + "appTitle": "Pola test codes", + "barcodeList": "Barcode List", + "description": "Description", + "code": "Barcode", + "addCode": "Add Barcode", + "error": { + "emptyDescription": "Description cannot be empty", + "emptyCode": "Barcode cannot be empty", + "invalidCode": "Invalid barcode" + }, + "codeType": "Code type", + "barcodesDescription": { + "companyNotVerified": "Company not verified", + "companyVerifiedWithFullScores": "Company verified with full scores", + "companyVerifiedWithIncompleteScores": "Company verified with incomplete scores", + "internalCode": "Internal Code", + "companyRegisteredOutsidePoland": "Company registered outside Poland", + "companyRegisteredIn": "Company registered in...", + "lidlOwnBrand": "Lidl's own brand", + "polaFriend": "Pola's Friend", + "extendedCompanyDescription": "Extended company description" + } +} diff --git a/lib/i18n/strings-pl.i18n.json b/lib/i18n/strings-pl.i18n.json new file mode 100644 index 0000000..488d09b --- /dev/null +++ b/lib/i18n/strings-pl.i18n.json @@ -0,0 +1,24 @@ +{ + "appTitle": "Kody testowe poli", + "barcodeList": "Lista Kodów Kreskowych", + "description": "Opis", + "code": "Kod kreskowy", + "addCode": "Dodaj kod kreskowy", + "error": { + "emptyDescription": "Opis nie może być pusty", + "emptyCode": "Kod kreskowy nie może być pusty", + "invalidCode": "Nieprawidłowy kod kreskowy" + }, + "codeType": "Typ kodu", + "barcodesDescription": { + "companyNotVerified": "Firma nie zweryfikowana", + "companyVerifiedWithFullScores": "Firma zweryfikowana z pełną punktacją", + "companyVerifiedWithIncompleteScores": "Firma zweryfikowana z niepełną punktacją", + "internalCode": "Kod wewnętrzny", + "companyRegisteredOutsidePoland": "Firma zarejestrowana poza Polską", + "companyRegisteredIn": "Firma zarejerstrowana w ...", + "lidlOwnBrand": "Marka własna Lidla", + "polaFriend": "Przyjaciel Poli", + "extendedCompanyDescription": "Rozszerzony opis firmy" + } +} \ No newline at end of file diff --git a/lib/i18n/strings.g.dart b/lib/i18n/strings.g.dart new file mode 100644 index 0000000..d8951e2 --- /dev/null +++ b/lib/i18n/strings.g.dart @@ -0,0 +1,308 @@ +/// Generated file. Do not edit. +/// +/// Original: lib/i18n +/// To regenerate, run: `dart run slang` +/// +/// Locales: 2 +/// Strings: 36 (18 per locale) +/// +/// Built on 2024-07-17 at 12:49 UTC + +// coverage:ignore-file +// ignore_for_file: type=lint + +import 'package:flutter/widgets.dart'; +import 'package:slang/builder/model/node.dart'; +import 'package:slang_flutter/slang_flutter.dart'; +export 'package:slang_flutter/slang_flutter.dart'; + +const AppLocale _baseLocale = AppLocale.en; + +/// Supported locales, see extension methods below. +/// +/// Usage: +/// - LocaleSettings.setLocale(AppLocale.en) // set locale +/// - Locale locale = AppLocale.en.flutterLocale // get flutter locale from enum +/// - if (LocaleSettings.currentLocale == AppLocale.en) // locale check +enum AppLocale with BaseAppLocale { + en(languageCode: 'en', build: Translations.build), + pl(languageCode: 'pl', build: _StringsPl.build); + + const AppLocale({required this.languageCode, this.scriptCode, this.countryCode, required this.build}); // ignore: unused_element + + @override final String languageCode; + @override final String? scriptCode; + @override final String? countryCode; + @override final TranslationBuilder build; + + /// Gets current instance managed by [LocaleSettings]. + Translations get translations => LocaleSettings.instance.translationMap[this]!; +} + +/// Method A: Simple +/// +/// No rebuild after locale change. +/// Translation happens during initialization of the widget (call of t). +/// Configurable via 'translate_var'. +/// +/// Usage: +/// String a = t.someKey.anotherKey; +/// String b = t['someKey.anotherKey']; // Only for edge cases! +Translations get t => LocaleSettings.instance.currentTranslations; + +/// Method B: Advanced +/// +/// All widgets using this method will trigger a rebuild when locale changes. +/// Use this if you have e.g. a settings page where the user can select the locale during runtime. +/// +/// Step 1: +/// wrap your App with +/// TranslationProvider( +/// child: MyApp() +/// ); +/// +/// Step 2: +/// final t = Translations.of(context); // Get t variable. +/// String a = t.someKey.anotherKey; // Use t variable. +/// String b = t['someKey.anotherKey']; // Only for edge cases! +class TranslationProvider extends BaseTranslationProvider { + TranslationProvider({required super.child}) : super(settings: LocaleSettings.instance); + + static InheritedLocaleData of(BuildContext context) => InheritedLocaleData.of(context); +} + +/// Method B shorthand via [BuildContext] extension method. +/// Configurable via 'translate_var'. +/// +/// Usage (e.g. in a widget's build method): +/// context.t.someKey.anotherKey +extension BuildContextTranslationsExtension on BuildContext { + Translations get t => TranslationProvider.of(this).translations; +} + +/// Manages all translation instances and the current locale +class LocaleSettings extends BaseFlutterLocaleSettings { + LocaleSettings._() : super(utils: AppLocaleUtils.instance); + + static final instance = LocaleSettings._(); + + // static aliases (checkout base methods for documentation) + static AppLocale get currentLocale => instance.currentLocale; + static Stream getLocaleStream() => instance.getLocaleStream(); + static AppLocale setLocale(AppLocale locale, {bool? listenToDeviceLocale = false}) => instance.setLocale(locale, listenToDeviceLocale: listenToDeviceLocale); + static AppLocale setLocaleRaw(String rawLocale, {bool? listenToDeviceLocale = false}) => instance.setLocaleRaw(rawLocale, listenToDeviceLocale: listenToDeviceLocale); + static AppLocale useDeviceLocale() => instance.useDeviceLocale(); + @Deprecated('Use [AppLocaleUtils.supportedLocales]') static List get supportedLocales => instance.supportedLocales; + @Deprecated('Use [AppLocaleUtils.supportedLocalesRaw]') static List get supportedLocalesRaw => instance.supportedLocalesRaw; + static void setPluralResolver({String? language, AppLocale? locale, PluralResolver? cardinalResolver, PluralResolver? ordinalResolver}) => instance.setPluralResolver( + language: language, + locale: locale, + cardinalResolver: cardinalResolver, + ordinalResolver: ordinalResolver, + ); +} + +/// Provides utility functions without any side effects. +class AppLocaleUtils extends BaseAppLocaleUtils { + AppLocaleUtils._() : super(baseLocale: _baseLocale, locales: AppLocale.values); + + static final instance = AppLocaleUtils._(); + + // static aliases (checkout base methods for documentation) + static AppLocale parse(String rawLocale) => instance.parse(rawLocale); + static AppLocale parseLocaleParts({required String languageCode, String? scriptCode, String? countryCode}) => instance.parseLocaleParts(languageCode: languageCode, scriptCode: scriptCode, countryCode: countryCode); + static AppLocale findDeviceLocale() => instance.findDeviceLocale(); + static List get supportedLocales => instance.supportedLocales; + static List get supportedLocalesRaw => instance.supportedLocalesRaw; +} + +// translations + +// Path: +class Translations implements BaseTranslations { + /// Returns the current translations of the given [context]. + /// + /// Usage: + /// final t = Translations.of(context); + static Translations of(BuildContext context) => InheritedLocaleData.of(context).translations; + + /// You can call this constructor and build your own translation instance of this locale. + /// Constructing via the enum [AppLocale.build] is preferred. + Translations.build({Map? overrides, PluralResolver? cardinalResolver, PluralResolver? ordinalResolver}) + : assert(overrides == null, 'Set "translation_overrides: true" in order to enable this feature.'), + $meta = TranslationMetadata( + locale: AppLocale.en, + overrides: overrides ?? {}, + cardinalResolver: cardinalResolver, + ordinalResolver: ordinalResolver, + ) { + $meta.setFlatMapFunction(_flatMapFunction); + } + + /// Metadata for the translations of . + @override final TranslationMetadata $meta; + + /// Access flat map + dynamic operator[](String key) => $meta.getTranslation(key); + + late final Translations _root = this; // ignore: unused_field + + // Translations + String get appTitle => 'Pola test codes'; + String get barcodeList => 'Barcode List'; + String get description => 'Description'; + String get code => 'Barcode'; + String get addCode => 'Add Barcode'; + late final _StringsErrorEn error = _StringsErrorEn._(_root); + String get codeType => 'Code type'; + late final _StringsBarcodesDescriptionEn barcodesDescription = _StringsBarcodesDescriptionEn._(_root); +} + +// Path: error +class _StringsErrorEn { + _StringsErrorEn._(this._root); + + final Translations _root; // ignore: unused_field + + // Translations + String get emptyDescription => 'Description cannot be empty'; + String get emptyCode => 'Barcode cannot be empty'; + String get invalidCode => 'Invalid barcode'; +} + +// Path: barcodesDescription +class _StringsBarcodesDescriptionEn { + _StringsBarcodesDescriptionEn._(this._root); + + final Translations _root; // ignore: unused_field + + // Translations + String get companyNotVerified => 'Company not verified'; + String get companyVerifiedWithFullScores => 'Company verified with full scores'; + String get companyVerifiedWithIncompleteScores => 'Company verified with incomplete scores'; + String get internalCode => 'Internal Code'; + String get companyRegisteredOutsidePoland => 'Company registered outside Poland'; + String get companyRegisteredIn => 'Company registered in...'; + String get lidlOwnBrand => 'Lidl\'s own brand'; + String get polaFriend => 'Pola\'s Friend'; + String get extendedCompanyDescription => 'Extended company description'; +} + +// Path: +class _StringsPl implements Translations { + /// You can call this constructor and build your own translation instance of this locale. + /// Constructing via the enum [AppLocale.build] is preferred. + _StringsPl.build({Map? overrides, PluralResolver? cardinalResolver, PluralResolver? ordinalResolver}) + : assert(overrides == null, 'Set "translation_overrides: true" in order to enable this feature.'), + $meta = TranslationMetadata( + locale: AppLocale.pl, + overrides: overrides ?? {}, + cardinalResolver: cardinalResolver, + ordinalResolver: ordinalResolver, + ) { + $meta.setFlatMapFunction(_flatMapFunction); + } + + /// Metadata for the translations of . + @override final TranslationMetadata $meta; + + /// Access flat map + @override dynamic operator[](String key) => $meta.getTranslation(key); + + @override late final _StringsPl _root = this; // ignore: unused_field + + // Translations + @override String get appTitle => 'Kody testowe poli'; + @override String get barcodeList => 'Lista Kodów Kreskowych'; + @override String get description => 'Opis'; + @override String get code => 'Kod kreskowy'; + @override String get addCode => 'Dodaj kod kreskowy'; + @override late final _StringsErrorPl error = _StringsErrorPl._(_root); + @override String get codeType => 'Typ kodu'; + @override late final _StringsBarcodesDescriptionPl barcodesDescription = _StringsBarcodesDescriptionPl._(_root); +} + +// Path: error +class _StringsErrorPl implements _StringsErrorEn { + _StringsErrorPl._(this._root); + + @override final _StringsPl _root; // ignore: unused_field + + // Translations + @override String get emptyDescription => 'Opis nie może być pusty'; + @override String get emptyCode => 'Kod kreskowy nie może być pusty'; + @override String get invalidCode => 'Nieprawidłowy kod kreskowy'; +} + +// Path: barcodesDescription +class _StringsBarcodesDescriptionPl implements _StringsBarcodesDescriptionEn { + _StringsBarcodesDescriptionPl._(this._root); + + @override final _StringsPl _root; // ignore: unused_field + + // Translations + @override String get companyNotVerified => 'Firma nie zweryfikowana'; + @override String get companyVerifiedWithFullScores => 'Firma zweryfikowana z pełną punktacją'; + @override String get companyVerifiedWithIncompleteScores => 'Firma zweryfikowana z niepełną punktacją'; + @override String get internalCode => 'Kod wewnętrzny'; + @override String get companyRegisteredOutsidePoland => 'Firma zarejestrowana poza Polską'; + @override String get companyRegisteredIn => 'Firma zarejerstrowana w ...'; + @override String get lidlOwnBrand => 'Marka własna Lidla'; + @override String get polaFriend => 'Przyjaciel Poli'; + @override String get extendedCompanyDescription => 'Rozszerzony opis firmy'; +} + +/// Flat map(s) containing all translations. +/// Only for edge cases! For simple maps, use the map function of this library. + +extension on Translations { + dynamic _flatMapFunction(String path) { + switch (path) { + case 'appTitle': return 'Pola test codes'; + case 'barcodeList': return 'Barcode List'; + case 'description': return 'Description'; + case 'code': return 'Barcode'; + case 'addCode': return 'Add Barcode'; + case 'error.emptyDescription': return 'Description cannot be empty'; + case 'error.emptyCode': return 'Barcode cannot be empty'; + case 'error.invalidCode': return 'Invalid barcode'; + case 'codeType': return 'Code type'; + case 'barcodesDescription.companyNotVerified': return 'Company not verified'; + case 'barcodesDescription.companyVerifiedWithFullScores': return 'Company verified with full scores'; + case 'barcodesDescription.companyVerifiedWithIncompleteScores': return 'Company verified with incomplete scores'; + case 'barcodesDescription.internalCode': return 'Internal Code'; + case 'barcodesDescription.companyRegisteredOutsidePoland': return 'Company registered outside Poland'; + case 'barcodesDescription.companyRegisteredIn': return 'Company registered in...'; + case 'barcodesDescription.lidlOwnBrand': return 'Lidl\'s own brand'; + case 'barcodesDescription.polaFriend': return 'Pola\'s Friend'; + case 'barcodesDescription.extendedCompanyDescription': return 'Extended company description'; + default: return null; + } + } +} + +extension on _StringsPl { + dynamic _flatMapFunction(String path) { + switch (path) { + case 'appTitle': return 'Kody testowe poli'; + case 'barcodeList': return 'Lista Kodów Kreskowych'; + case 'description': return 'Opis'; + case 'code': return 'Kod kreskowy'; + case 'addCode': return 'Dodaj kod kreskowy'; + case 'error.emptyDescription': return 'Opis nie może być pusty'; + case 'error.emptyCode': return 'Kod kreskowy nie może być pusty'; + case 'error.invalidCode': return 'Nieprawidłowy kod kreskowy'; + case 'codeType': return 'Typ kodu'; + case 'barcodesDescription.companyNotVerified': return 'Firma nie zweryfikowana'; + case 'barcodesDescription.companyVerifiedWithFullScores': return 'Firma zweryfikowana z pełną punktacją'; + case 'barcodesDescription.companyVerifiedWithIncompleteScores': return 'Firma zweryfikowana z niepełną punktacją'; + case 'barcodesDescription.internalCode': return 'Kod wewnętrzny'; + case 'barcodesDescription.companyRegisteredOutsidePoland': return 'Firma zarejestrowana poza Polską'; + case 'barcodesDescription.companyRegisteredIn': return 'Firma zarejerstrowana w ...'; + case 'barcodesDescription.lidlOwnBrand': return 'Marka własna Lidla'; + case 'barcodesDescription.polaFriend': return 'Przyjaciel Poli'; + case 'barcodesDescription.extendedCompanyDescription': return 'Rozszerzony opis firmy'; + default: return null; + } + } +} diff --git a/lib/i18n/strings.i18n.json b/lib/i18n/strings.i18n.json new file mode 100644 index 0000000..488d09b --- /dev/null +++ b/lib/i18n/strings.i18n.json @@ -0,0 +1,24 @@ +{ + "appTitle": "Kody testowe poli", + "barcodeList": "Lista Kodów Kreskowych", + "description": "Opis", + "code": "Kod kreskowy", + "addCode": "Dodaj kod kreskowy", + "error": { + "emptyDescription": "Opis nie może być pusty", + "emptyCode": "Kod kreskowy nie może być pusty", + "invalidCode": "Nieprawidłowy kod kreskowy" + }, + "codeType": "Typ kodu", + "barcodesDescription": { + "companyNotVerified": "Firma nie zweryfikowana", + "companyVerifiedWithFullScores": "Firma zweryfikowana z pełną punktacją", + "companyVerifiedWithIncompleteScores": "Firma zweryfikowana z niepełną punktacją", + "internalCode": "Kod wewnętrzny", + "companyRegisteredOutsidePoland": "Firma zarejestrowana poza Polską", + "companyRegisteredIn": "Firma zarejerstrowana w ...", + "lidlOwnBrand": "Marka własna Lidla", + "polaFriend": "Przyjaciel Poli", + "extendedCompanyDescription": "Rozszerzony opis firmy" + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 1091047..bb39c19 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; +import 'i18n/strings.g.dart'; import 'barcode_item.dart'; import 'barcodes_page.dart'; void main() { - runApp(const MyApp()); + WidgetsFlutterBinding.ensureInitialized(); + LocaleSettings.useDeviceLocale(); + runApp(TranslationProvider(child: const MyApp())); } class MyApp extends StatelessWidget { @@ -11,9 +14,11 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { + final translations = Translations.of(context); return MaterialApp( - title: 'Kody Testowe Poli', - home: BarcodesPage(barcodes: BarcodeItem.barcodes), + title: (translations.appTitle), + home: BarcodesPage( + barcodes: BarcodeItem.barcodes(translations)), ); } } diff --git a/pubspec.lock b/pubspec.lock index 9d4387d..478e15c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + csv: + dependency: transitive + description: + name: csv + sha256: c6aa2679b2a18cb57652920f674488d89712efaf4d3fdf2e537215b35fc19d6c + url: "https://pub.dev" + source: hosted + version: "6.0.0" cupertino_icons: dependency: "direct main" description: @@ -91,6 +99,14 @@ packages: description: flutter source: sdk version: "0.0.0" + json2yaml: + dependency: transitive + description: + name: json2yaml + sha256: da94630fbc56079426fdd167ae58373286f603371075b69bf46d848d63ba3e51 + url: "https://pub.dev" + source: hosted + version: "3.0.1" leak_tracker: dependency: transitive description: @@ -168,6 +184,22 @@ packages: description: flutter source: sdk version: "0.0.99" + slang: + dependency: "direct main" + description: + name: slang + sha256: f68f6d6709890f85efabfb0318e9d694be2ebdd333e57fe5cb50eee449e4e3ab + url: "https://pub.dev" + source: hosted + version: "3.31.1" + slang_flutter: + dependency: "direct main" + description: + name: slang_flutter + sha256: f8400292be49c11697d94af58d7f7d054c91af759f41ffe71e4e5413871ffc62 + url: "https://pub.dev" + source: hosted + version: "3.31.0" source_span: dependency: transitive description: @@ -232,6 +264,22 @@ packages: url: "https://pub.dev" source: hosted version: "13.0.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" sdks: dart: ">=3.3.4 <4.0.0" - flutter: ">=1.16.0" + flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 74303b6..a6899c3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,8 @@ dependencies: flutter: sdk: flutter barcode_widget: ^2.0.1 + slang: ^3.0.0 + slang_flutter: ^3.0.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.