-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Impaktfull/feat/formatting
feat: Added formatting function to format your locale files
- Loading branch information
Showing
15 changed files
with
109 additions
and
74 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Automated version bump | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
bump_version: | ||
name: Version bump on main | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.IMPAKTFULL_GITHUB_PAT }} | ||
ref: ${{ github.ref }} | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18 | ||
- name: Automated version bump | ||
uses: impaktfull/gh_action_dart_conventional_release@main | ||
with: | ||
tag-prefix: 'v' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Publish to pub.dev | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
jobs: | ||
publish: | ||
permissions: | ||
id-token: write # Required for authentication using OIDC | ||
uses: Impaktfull/gh_action_dart_conventional_release/.github/workflows/flutter_release.yml@main | ||
with: | ||
environment: 'pub.dev' |
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
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,6 @@ | ||
import 'package:locale_gen/locale_gen.dart'; | ||
|
||
void main() { | ||
final params = LocaleGenParams('locale_gen'); | ||
LocaleGenFormatter.format(params); | ||
} |
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
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,2 +1,3 @@ | ||
export 'src/locale_gen_params.dart'; | ||
export 'src/locale_gen_writer.dart'; | ||
export 'src/locale_gen_formatter.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
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,30 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:locale_gen/locale_gen.dart'; | ||
import 'package:locale_gen/src/case_util.dart'; | ||
|
||
class LocaleGenFormatter { | ||
const LocaleGenFormatter._(); | ||
|
||
static void format(LocaleGenParams params) { | ||
final files = params.languages | ||
.map((language) => File('${params.assetsDir}$language.json')); | ||
const jsonEncoder = JsonEncoder.withIndent(' '); | ||
for (final file in files) { | ||
print('Formatting ${file.path}'); | ||
final content = file.readAsStringSync(); | ||
final json = jsonDecode(content) as Map<String, dynamic>; | ||
final newJson = {}; | ||
final sortedKeys = json.keys.toList()..sort(); | ||
for (final key in sortedKeys) { | ||
final value = json[key]; | ||
newJson[CaseUtil.getSnakeCase(key)] = value; | ||
} | ||
|
||
final data = jsonEncoder.convert(newJson); | ||
file.writeAsStringSync(data); | ||
} | ||
print('Formatting done!'); | ||
} | ||
} |