From 2a09726451e9b7f699222c05749f009034577428 Mon Sep 17 00:00:00 2001 From: iLTeoooD Date: Sun, 13 Mar 2022 13:25:00 +0100 Subject: [PATCH] Fix for 189 --- CHANGELOG.md | 5 ++++- example/lib/network_example.dart | 19 ++++++------------- .../network_file_translation_loader.dart | 3 ++- pubspec.yaml | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3560188..241b425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -258,4 +258,7 @@ Fix for #184 ## [0.32.0] Fix for #186 -Recursively merge the translation map with the fallback map \ No newline at end of file +Recursively merge the translation map with the fallback map + +## [0.32.1] +Fix for #189 \ No newline at end of file diff --git a/example/lib/network_example.dart b/example/lib/network_example.dart index 094b77c..c41d056 100644 --- a/example/lib/network_example.dart +++ b/example/lib/network_example.dart @@ -6,20 +6,13 @@ import 'package:flutter_i18n/loaders/decoders/json_decode_strategy.dart'; import 'package:flutter_i18n/widgets/I18nText.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -class CustomNetworkFileTranslationLoader extends NetworkFileTranslationLoader { - CustomNetworkFileTranslationLoader({required baseUri}) - : super(baseUri: baseUri, decodeStrategies: [JsonDecodeStrategy()]); - - Uri resolveUri(final String fileName, final String extension) { - return baseUri; - } -} - Future main() async { final FlutterI18nDelegate flutterI18nDelegate = FlutterI18nDelegate( - translationLoader: CustomNetworkFileTranslationLoader( - baseUri: Uri.https("postman-echo.com", "get", - {"title": "Basic network example", "content": "Translated content"}), + translationLoader: NetworkFileTranslationLoader( + baseUri: Uri.https("lalgodepaulo.com", "translations"), + useCountryCode: false, + fallbackFile: 'en', + decodeStrategies: [JsonDecodeStrategy()] ), ); @@ -66,7 +59,7 @@ class MyHomePage extends StatelessWidget { }, ), I18nText( - "args.content", + "tutoriel_page.timetable", child: Text(""), ), ], diff --git a/lib/loaders/network_file_translation_loader.dart b/lib/loaders/network_file_translation_loader.dart index 3a3ca60..4cd4f1f 100644 --- a/lib/loaders/network_file_translation_loader.dart +++ b/lib/loaders/network_file_translation_loader.dart @@ -30,6 +30,7 @@ class NetworkFileTranslationLoader extends FileTranslationLoader { } Uri resolveUri(final String fileName, final String extension) { - return baseUri.resolve('$fileName.$extension'); + final fileToFind = '$fileName.$extension'; + return this.baseUri.replace(path: '${this.baseUri.path}/$fileToFind'); } } diff --git a/pubspec.yaml b/pubspec.yaml index 2cf967e..ebce681 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_i18n description: i18n made easy for Flutter. With flutter_i18n you can make your app international, using just a simple .json file! -version: 0.32.0 +version: 0.32.1 homepage: https://github.com/ilteoood/flutter_i18n issue_tracker: https://github.com/ilteoood/flutter_i18n/issues