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

Update language download during install to use existing folder if present #28425

Merged
merged 4 commits into from
Dec 4, 2023

Conversation

demeritcowboy
Copy link
Contributor

@demeritcowboy demeritcowboy commented Dec 2, 2023

Overview

For example if you pre-install the language files somewhere else, the install process downloads another copy elsewhere unless you reconfigure your install script.

e.g. The demo builds are currently popping up a status check saying it has two l10n folders.

Before

It ALWAYS creates and downloads the folder.

After

  1. It will look for an existing folder and use that to determine how to set the l10n folder.
  2. Once the path is chosen, it won't re-download the given language if it's already downloaded in that location.

Note there are two steps involved: How to determine the l10n location, and whether to download.

Technical Details

Commit 1 looks messy but is mostly the same as before except that it additionally checks if the folder exists and if it doesn't goes on to the next candidate. The preferred order of how it ends up setting ['civicrm.l10n'] is the same as before though:

  • If you've somehow worked around some limitations and managed to set ['civicrm.l10n'] already, that's the first choice.
  • If CIVICRM_L10N_BASEDIR is set either via define or environment variable, that's the second choice.
  • ['civicrm.private'] is the third choice.
  • The old-timey "standard" location of the civicrm root is the last choice.

Commit 2 is straightforward if viewed without whitespace. It just now only downloads if the language subfolder doesn't already exist.

Commits 3 and 4 are just extra.

Comments

Some examples:

  1. Installing via the new UI installer on a brand new setup with no additional setup: It will create and download in sites/default/files/civicrm/l10n (or cms equivalent).
  2. Ditto for cv.
  3. CIVICRM_L10N_BASEDIR=/path/to/l10n cv core:install --lang=aa_AA ... will check if /path/to/l10n in exists, and if it does will use that, and if not will use sites/default/files/civicrm/l10n. Then, if the aa_AA lang is already downloaded in the determined location, it won't download again.
  4. You've already somehow got the language files in civicrm_root/l10n, but then you create some other folder /path/to/l10n and you run CIVICRM_L10N_BASEDIR=/path/to/l10n cv core:install --lang=aa_AA .... It will use /path/to/l10n and download another copy there. The existing status check will tell you about it and you can decide what to do.
  5. You've already somehow got the language files in civicrm_root/l10n, and you run cv core:install --lang=aa_AA .... It will use the files you already have in civicrm_root/l10n.

Copy link

civibot bot commented Dec 2, 2023

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Dec 2, 2023
@demeritcowboy
Copy link
Contributor Author

jenkins retest this please

1 similar comment
@demeritcowboy
Copy link
Contributor Author

jenkins retest this please

@totten
Copy link
Member

totten commented Dec 4, 2023

Very nice @demeritcowboy.

I gave it a bit of a run (with/without l10n data in a few arrangements), and it appeared to work nicely. Good to get this in before freeze.

@totten totten merged commit a2353ce into civicrm:master Dec 4, 2023
@demeritcowboy
Copy link
Contributor Author

Thanks!
{ts}l10n{/ts}

@demeritcowboy demeritcowboy deleted the lang-eco branch December 5, 2023 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants