feat: add l10n
localization and set configuration
#14
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
name: Linting & Tests Validation | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lint_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24.5' | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Run Dart Format Check | |
run: | | |
dart format . --set-exit-if-changed --output none || ( | |
echo "Code formatting issues detected. Run 'dart format .' and commit the changes."; | |
exit 1; | |
) | |
# Asset Generation and Check | |
- name: Generate Asset Files | |
run: | | |
# Command to rebuild asset files | |
dart run build_runner build --delete-conflicting-outputs --build-filter="lib/src/core/utils/gen/assets/*.dart" || ( | |
echo "Error: Failed to generate asset files."; | |
exit 1; | |
) | |
- name: Check Asset Files Changes | |
run: | | |
# Check if there are changes after generating asset files | |
git diff --exit-code lib/src/core/utils/gen/assets || ( | |
echo "Error: Asset files are outdated. Run the generation command and commit the changes."; | |
exit 1; | |
) | |
# Localization Generation and Check | |
- name: Generate Localization Files | |
id: gen_l10n | |
run: | | |
# Run the command to generate localization files and capture the output | |
output=$(flutter gen-l10n --arb-dir=assets/translations) | |
echo "$output" | |
# Check if there are untranslated messages in the output | |
if echo "$output" | grep -q "untranslated message"; then | |
echo "::error file=lib/l10n/l10n.yaml::Error: Untranslated messages detected in your localization files." | |
echo "::error::There are untranslated messages in the following languages:" | |
echo "$output" | grep "untranslated message" | |
echo "::error::Please ensure that all translations are provided in the respective .arb files." | |
exit 1 | |
fi | |
- name: Check Localization Files | |
run: | | |
git diff --exit-code lib/l10n/ || ( | |
echo "Localization files are outdated. Run 'flutter gen-l10n' and commit changes."; | |
exit 1; | |
) | |
- name: Run Flutter Analyze | |
run: flutter analyze | |
- name: Run tests | |
run: flutter test | |
merge_check: | |
runs-on: ubuntu-latest | |
needs: lint_and_test | |
if: ${{ success() }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Merge Pull Request | |
run: echo "Linting and tests passed successfully. Merge request is ready for merge." |