Skip to content

Commit

Permalink
Fix for 189
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Mar 13, 2022
1 parent 7df2686 commit 2a09726
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,7 @@ Fix for #184

## [0.32.0]
Fix for #186
Recursively merge the translation map with the fallback map
Recursively merge the translation map with the fallback map

## [0.32.1]
Fix for #189
19 changes: 6 additions & 13 deletions example/lib/network_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
),
);

Expand Down Expand Up @@ -66,7 +59,7 @@ class MyHomePage extends StatelessWidget {
},
),
I18nText(
"args.content",
"tutoriel_page.timetable",
child: Text(""),
),
],
Expand Down
3 changes: 2 additions & 1 deletion lib/loaders/network_file_translation_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 2a09726

Please sign in to comment.