Skip to content

Commit

Permalink
Merge branch 'removal/firebase-references' of https://github.com/Abhi…
Browse files Browse the repository at this point in the history
…sheksainii/talawa into removal/firebase-references
  • Loading branch information
Abhisheksainii committed Jan 2, 2024
2 parents 461979e + dcac570 commit d3a768f
Show file tree
Hide file tree
Showing 65 changed files with 3,980 additions and 796 deletions.
168 changes: 168 additions & 0 deletions .github/workflows/compare_translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
"""
Script to encourage more efficient coding practices.
Methodology:
Utility for comparing translations between default and other languages.
This module defines a function to compare two translations
and print any missing keys in the other language's translation.
Attributes:
FileTranslation : Named tuple to represent a combination of file and missing translations.
Fields:
- file (str): The file name.
- missing_translations (list): List of missing translations.
Functions:
compare_translations(default_translation, other_translation):
Compare two translations and print missing keys.
load_translation(filepath):
Load translation from a file.
check_translations():
Load the default translation and compare it with other translations.
main():
The main function to run the script.
Parses command-line arguments, checks for the existence of the specified directory,
and then calls check_translations with the provided or default directory.
Usage:
This script can be executed to check and print missing
translations in other languages based on the default English translation.
Example:
python compare_translations.py
NOTE:
This script complies with our python3 coding and documentation standards
and should be used as a reference guide. It complies with:
1) Pylint
2) Pydocstyle
3) Pycodestyle
4) Flake8
"""
# standard imports
import argparse
import json
import os
import sys
from collections import namedtuple

# Named tuple for file and missing translations combination
FileTranslation = namedtuple("FileTranslation", ["file", "missing_translations"])


def compare_translations(default_translation, other_translation, default_file, other_file):
"""Compare two translations and return detailed info about missing/mismatched keys.
Args:
default_translation (dict): The default translation (en.json).
other_translation (dict): The other language translation.
default_file (str): The name of the default translation file.
other_file (str): The name of the other translation file.
Returns:
list: A list of detailed error messages for each missing/mismatched key.
"""
errors = []

# Check for missing keys in other_translation
for key in default_translation:
if key not in other_translation:
error_msg = f"Missing Key: '{key}' - This key from '{default_file}' is missing in '{other_file}'."
errors.append(error_msg)

# Check for keys in other_translation that don't match any in default_translation
for key in other_translation:
if key not in default_translation:
error_msg = f"Error Key: '{key}' - This key in '{other_file}' does not match any key in '{default_file}'."
errors.append(error_msg)

return errors




def load_translation(filepath):
"""Load translation from a file.
Args:
filepath: Path to the translation file
Returns:
translation: Loaded translation
"""
with open(filepath, "r", encoding="utf-8") as file:
translation = json.load(file)
return translation



def check_translations(directory):
"""Load default translation and compare with other translations.
Args:
directory (str): The directory containing translation files.
Returns:
None
"""
default_file = "en.json"
default_translation = load_translation(os.path.join(directory, default_file))
translations = os.listdir(directory)
translations.remove(default_file) # Exclude default translation

error_found = False

for translation_file in translations:
other_file = os.path.join(directory, translation_file)
other_translation = load_translation(other_file)

# Compare translations and get detailed error messages
errors = compare_translations(default_translation, other_translation, default_file, translation_file)
if errors:
error_found = True
print(f"File {translation_file} has missing translations for:")
for error in errors:
print(f" - {error}")

if error_found:
sys.exit(1) # Exit with an error status code
else:
print("All translations are present")
sys.exit(0)


def main():
"""
Parse command-line arguments, check for the existence of the specified directory,
and call check_translations with the provided or default directory.
"""
parser = argparse.ArgumentParser(
description="Check and print missing translations for all non-default languages."
)
parser.add_argument(
"--directory",
type=str,
nargs="?",
default=os.path.join(os.getcwd(), "lang"),
help="Directory containing translation files(relative to the root directory).",
)
args = parser.parse_args()

if not os.path.exists(args.directory):
print(f"Error: The specified directory '{args.directory}' does not exist.")
sys.exit(1)

check_translations(args.directory)


if __name__ == "__main__":
main()
27 changes: 16 additions & 11 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ on:
- 'master'

env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}

jobs:
Flutter-Codebase-Check:
name: Checking codebase
Expand All @@ -27,11 +27,11 @@ jobs:
- uses: actions/checkout@v3
with:
# ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '12.0'
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.0'
Expand Down Expand Up @@ -66,11 +66,16 @@ jobs:
git checkout temp_branch
pip install GitPython
python ./.github/workflows/check_ignore.py --repository ${{github.repository}} --merge_branch_name ${{github.head_ref}}
- name: Compare translation files
run: |
chmod +x .github/workflows/compare_translations.py
python .github/workflows/compare_translations.py --directory lang
- name: Analysing codebase for default linting
run: flutter analyze --no-pub
- name: Analysing codebase for custom linting
run: flutter pub run custom_lint
- name : Changed Files
- name: Changed Files
id: changed-files
uses: tj-actions/changed-files@v35
- name: List all changed files
Expand Down Expand Up @@ -104,7 +109,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '12.0'
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.0'
Expand All @@ -118,13 +123,13 @@ jobs:
with:
verbose: true
fail_ci_if_error: false
name: '${{env.CODECOV_UNIQUE_NAME}}'
name: '${{env.CODECOV_UNIQUE_NAME}}'
- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: './coverage/lcov.info'
min_coverage: 87.0
path: './coverage/lcov.info'
min_coverage: 90.0

Android-Build:
name: Testing build for android
runs-on: ubuntu-latest
Expand All @@ -134,7 +139,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '12.0'
java-version: '12.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.0'
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ jobs:
This may or may not be stable, so please have a look at the stable release(s).
iOS-Build:
name: Testing build for iOS
name: iOS Build and Relaese
runs-on: macos-latest
needs: Flutter-Testing
steps:
Expand All @@ -235,3 +235,27 @@ jobs:
architecture: x64
- name: Building for ios
run: flutter build ios --release --no-codesign
# '--no-codesign' is used for building without code signing.
# For actual distribution, proper code signing is required.

########################################################
## Package the app as an .ipa and create a release ##
########################################################

- name: Releasing for iOS
run: |
mkdir Payload
cp -r build/ios/iphoneos/Runner.app Payload/Runner.app
zip -r app.ipa Payload
# This packages the Runner.app into an .ipa file

- uses: ncipollo/release-action@v1
with:
name: "Automated iOS Release"
artifacts: "app-release.ipa"
allowUpdates: "true"
generateReleaseNotes: false
tag: "automated"
body: |
This is an automated release, triggered by a recent push.
This may or may not be stable, so please have a look at the stable release(s).
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,12 @@ test/fixtures/core
# Ignoring file that are generated during talawa testing and firebase initialization
genhtml.perl
test_img.png


# Ignoring Node files that are generated if user uses any node command which is not required for the project
node_modules/
package.json
package-lock.json
yarn.lock
npm-debug.log
yarn-error.log
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ The process of proposing a change to Talawa can be summarized as:
1. Pull requests that don't meet the minimum test coverage levels will not be accepted. This may mean that you will have to create tests for code you did not write. You can decide which part of the code base needs additional tests if this happens to you.
1. **_Testing_:**
1. Test using the `flutter test` command.
1. Review [Flutter's official introduction to unit testing](https://docs.flutter.dev/cookbook/testing/unit/introduction)
1. Here are some useful flutter test videos
1. [State Management With Provider](https://www.raywenderlich.com/6373413-state-management-with-provider)
1. [Unit Testing With Flutter: Getting Started](https://www.raywenderlich.com/6926998-unit-testing-with-flutter-getting-started)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Talawa

[💬 Join the community on Slack](https://join.slack.com/t/thepalisadoes-dyb6419/shared_invite/zt-28cswzsds-gfw~qPoxZOZv3vOYKokDKw)
[💬 Join the community on Slack](https://join.slack.com/t/thepalisadoes-dyb6419/shared_invite/zt-29oltereu-qJ931LcKxswuCAy29iA9WA)

![talawa-logo-lite-200x200](https://github.com/PalisadoesFoundation/talawa-admin/assets/16875803/26291ec5-d3c1-4135-8bc7-80885dff613d)

Expand Down
15 changes: 13 additions & 2 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@
"Cancel": "Abbrechen",
"Done": "Fertig",
"Explore Events": "Veranstaltungen erkunden",
"Filters": "Filter",
"Filter by Date": "Filtern nach Datum",
"All Events": "Alle Veranstaltungen",
"Show all events": "Alle Veranstaltungen anzeigen",
"Show all events created by you": "Alle Veranstaltungen anzeigen, die von Ihnen erstellt wurden",
"Registered Events": "Registrierte Veranstaltungen",
"Show all events you have registered": "Alle Veranstaltungen anzeigen, für die Sie sich registriert haben",
"Show events for all": "Alle Veranstaltungen anzeigen",
"Show invite-only events": "Nur Einladungsveranstaltungen anzeigen",

"Add Date": "Datum hinzufügen",
"Event": "Vorfall",
"My Events": "Meine Veranstaltungen",
Expand Down Expand Up @@ -152,7 +162,6 @@
"Logout": "Ausloggen",
"Settings": "Einstellungen",
"Dark Theme": "Dunkles Thema",

"Error": "Fout",
"Warning": "Waarschuwing",
"Information": "Informatie",
Expand All @@ -162,5 +171,7 @@
"Notification Feature is not installed": "Meddelelsesfunktionen er ikke installeret",
"For complete access, please": "Für vollständigen Zugriff bitte",
" join an organization.": " einer Organisation beitreten.",
"JOIN":"BEITRETEN"
"JOIN":"BEITRETEN",
"Camera": "Kamera",
"Gallery": "Galerie"
}
Loading

0 comments on commit d3a768f

Please sign in to comment.