diff --git a/lib/src/csv_asset_loader.dart b/lib/src/csv_asset_loader.dart index e363570..2a7ecfb 100644 --- a/lib/src/csv_asset_loader.dart +++ b/lib/src/csv_asset_loader.dart @@ -11,12 +11,20 @@ import 'package:flutter/services.dart'; // class CsvAssetLoader extends AssetLoader { CSVParser? csvParser; + final bool useAutodetect; + + CsvAssetLoader({ + this.useAutodetect = true, + }); @override Future> load(String path, Locale locale) async { if (csvParser == null) { log('easy localization loader: load csv file $path'); - csvParser = CSVParser(await rootBundle.loadString(path)); + csvParser = CSVParser( + await rootBundle.loadString(path), + useAutodetect: useAutodetect, + ); } else { log('easy localization loader: CSV parser already loaded, read cache'); } diff --git a/pubspec.yaml b/pubspec.yaml index f4e9b0c..fa54fa9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: connectivity_plus: ^5.0.1 - csv: ^5.0.1 + csv: ^6.0.0 easy_localization: ^3.0.3 flutter: { sdk: flutter } http: ^1.1.0 diff --git a/test/easy_localization_loader_test.dart b/test/easy_localization_loader_test.dart index 184340f..10b2bdb 100644 --- a/test/easy_localization_loader_test.dart +++ b/test/easy_localization_loader_test.dart @@ -13,6 +13,8 @@ void main() { 'str\ten_US\t$localeName\r\nscreen_language\tInterface language\tЯзык интерфейса\r\n'; const testCommaCRLFString = 'str,en_US,$localeName\r\nscreen_language,Interface language,Язык интерфейса\r\n'; + const testCommaQuotesInsideCRLFString = + 'str,en_US,$localeName\r\nscreen_language,"Interface language, Test","Язык интерфейса, Тест"\r\n'; Map getResult( String testString, @@ -45,6 +47,11 @@ void main() { {'screen_language': 'Язык интерфейса'}, getResult(testCommaCRLFString, localeName), ); + output( + 'testCommaQuotesInsideCRLFString'.toUpperCase(), + {'screen_language': 'Язык интерфейса, Тест'}, + getResult(testCommaQuotesInsideCRLFString, localeName, false), + ); output( 'testTabLFString, autodetect = false'.toUpperCase(), {},