-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ArbAssetLoader #43
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: PR Check | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
uses: ./.github/workflows/test.yml | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Release to pub.dev | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
uses: ./.github/workflows/test.yml | ||
secrets: inherit | ||
|
||
publish: | ||
needs: [test] | ||
name: Publish | ||
permissions: | ||
id-token: write # This is required for authentication using OIDC | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: dart-lang/setup-dart@v1 | ||
|
||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: "stable" | ||
|
||
- name: Install dependencies | ||
run: dart pub get | ||
|
||
- name: code format | ||
run: dart format lib/*/*.dart lib/*.dart | ||
|
||
- name: Publish | ||
run: dart pub publish --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Test | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '12.x' | ||
- uses: subosito/flutter-action@v1 | ||
with: | ||
channel: 'stable' | ||
|
||
- name: Install packages dependencies | ||
run: flutter pub get | ||
|
||
- name: Analyze the project's Dart code | ||
run: flutter analyze | ||
|
||
- name: Run tests | ||
run: flutter test | ||
|
||
- name: Run tests coverage | ||
run: flutter test --coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
## [0.0.1] | ||
## 2.0.1 | ||
|
||
- initial release | ||
- Extend delimiters for csv loader | ||
|
||
## 2.0.0 | ||
|
||
- **BREAKING**: The local `AssetLoader` class deleted, now using the one from | ||
[easy_localization](https://pub.dev/documentation/easy_localization/latest/easy_localization/AssetLoader-class.html) itself. | ||
- **BREAKING**: Depends on [connectivity_plus](https://pub.dev/packages/connectivity_plus) ^4.0.0 | ||
and [http](https://pub.dev/packages/http) ^1.0.0. | ||
- Const constructors in: | ||
- `FileAssetLoader` | ||
- `HttpAssetLoader` | ||
- `JsonAssetLoader` | ||
- `TestsAssetLoader` | ||
- `XmlAssetLoader` | ||
- `YamlAssetLoader` | ||
- Fixed deprecations | ||
|
||
## 0.0.1 | ||
|
||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Contributing | ||
|
||
## Release process | ||
|
||
1. Make sure that the changelog is updated | ||
|
||
2. Make sure that the version in pubspec.yaml is correct | ||
|
||
3. Create a release in the github UI. Name the release like the version, but with a v (3.7.5 -> v3.7.5). Name the tag like the release | ||
|
||
4. A pipeline will run and deploy the new version to pub.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
library easy_localization_loader; | ||
|
||
export 'package:easy_localization_loader/src/csv_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/file_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/json_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/http_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/csv_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/yaml_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/xml_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/tests_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/json_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/smart_network_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/tests_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/xml_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/yaml_asset_loader.dart'; | ||
export 'package:easy_localization_loader/src/arb_asset_loader.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:convert'; | ||
import 'dart:developer'; | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/services.dart'; | ||
|
||
import 'package:easy_localization/easy_localization.dart'; | ||
|
||
class ArbAssetLoader extends AssetLoader { | ||
const ArbAssetLoader(); | ||
|
||
String getLocalePath(String basePath, Locale locale) { | ||
return '$basePath/${locale.toStringWithSeparator(separator: "-")}.arb'; | ||
} | ||
|
||
@override | ||
Future<Map<String, dynamic>> load(String path, Locale locale) async { | ||
var localePath = getLocalePath(path, locale); | ||
log('easy localization loader: load arb file $localePath'); | ||
return jsonDecode(await rootBundle.loadString(localePath)); | ||
} | ||
} | ||
|
||
// Loader for single json file | ||
class ArbSingleAssetLoader extends AssetLoader { | ||
Map? jsonData; | ||
|
||
@override | ||
Future<Map<String, dynamic>> load(String path, Locale locale) async { | ||
if (jsonData == null) { | ||
log('easy localization loader: load arb file $path'); | ||
jsonData = jsonDecode(await rootBundle.loadString(path)); | ||
} else { | ||
log('easy localization loader: arb already loaded, read cache'); | ||
} | ||
return jsonData![locale.toString()]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
// | ||
// | ||
// | ||
// | ||
import 'dart:convert'; | ||
import 'dart:developer'; | ||
import 'dart:ui'; | ||
|
||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
import 'asset_loader.dart'; | ||
|
||
class HttpAssetLoader extends AssetLoader { | ||
const HttpAssetLoader(); | ||
|
||
@override | ||
Future<Map<String, dynamic>> load(String path, Locale locale) async { | ||
log('easy localization loader: load http $path'); | ||
try { | ||
var url = Uri.parse(path); | ||
var url = Uri.parse('$path/${locale.toLanguageTag()}.json'); | ||
return http | ||
.get(url) | ||
.then((response) => json.decode(response.body.toString())); | ||
.then((response) => json.decode(utf8.decode(response.bodyBytes))); | ||
} catch (e) { | ||
//Catch network exceptions | ||
return Future.value(); | ||
return {}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert formating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted