Skip to content
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

Fixes #448 : Improve legal code language selection/fallback #501

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rahulptl165
Copy link

Fixes

Description

This pull request implements new functionality for managing legal code translations in the system, addressing the need for:

  1. Populating the settings.LANGUAGES_AVAILABLE_LEGAL_CODE variable with legal code translations using a new function load_legal_code_translations().
  2. Adding a function get_default_language_for_jurisdiction_legal_code() to determine the default language for a given jurisdiction, considering the available legal code translations.
  3. Rename function get_default_language_for_jurisdiction_deed() to get_default_language_for_jurisdiction_deed_ux().
  4. Rename variable settings.LANGUAGES_MOSTLY_TRANSLATED to settings.LANGUAGES_AVAILABLE_DEEDS_UX.

These additions align with the existing structure for deeds and UX translations, ensuring consistency across the system.

Technical details

New Functions

  1. load_legal_code_translations()
  • Iterates through legal code PO files obtained from get_legal_code_pofiles().
  • Calculates translation percentages and filters languages based on settings.TRANSLATION_THRESHOLD.
  • Populates settings.LANGUAGES_AVAILABLE_LEGAL_CODE with languages meeting the criteria.
  • Stores metadata for translations in settings.DEEDS_UX_PO_FILE_INFO.
  1. get_default_language_for_jurisdiction_legal_code()
  • Uses DEFAULT_JURISDICTION_LANGUAGES to determine the default language for a jurisdiction.
  • Falls back to settings.LANGUAGE_CODE if the language is unavailable in settings.LANGUAGES_AVAILABLE_LEGAL_CODE.
  1. get_legal_code_pofiles()
  • Retrieves a sorted list of legal code PO files by iterating over directories in settings.LEGAL_CODE_LOCALE_PATH.
  • Filters valid PO files based on their paths.

Key Updates

  • Ensured settings.LANGUAGES_AVAILABLE_LEGAL_CODE is dynamically populated during runtime for accurate jurisdiction language lookups.
  • Replaced get_default_language_for_jurisdiction_naive() function with a get_default_language_for_jurisdiction_legal_code() function.
  • Rename settings.LANGUAGES_AVAILABLE_DEEDS_UX to settings.LANGUAGES_AVAILABLE_DEEDS_UX
  • The new functions follow the same structure and logic as existing deeds and UX translation functions, promoting code consistency and maintainability.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main or master).
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

For the purposes of this DCO, "license" is equivalent to "license or public domain dedication," and "open source license" is equivalent to "open content license or public domain dedication."

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@rahulptl165 rahulptl165 requested review from a team as code owners January 13, 2025 21:33
@rahulptl165 rahulptl165 requested review from TimidRobot and possumbilities and removed request for a team January 13, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

[Feature] Improve legal code language selection/fallback
1 participant