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

Drupal locale set via ENV #113

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

Conversation

tyler36
Copy link
Contributor

@tyler36 tyler36 commented Feb 22, 2023

The Problem/Issue/Bug

Drupal defaults to English locale.

How this PR Solves The Problem

This PR allows the user to set Drupal's locale via an ENV.

drush si is run with the locale being set to DP_INSTALL_LOCALE.
DP_INSTALL_LOCALE defaults to English(`en') if not set.

No attempts are made to validate the locale code passed to drush.

Manual Testing Instructions

Ideally, we should be able to pass the variable via the URL similar to DP_INSTALL_PROFILE.
I'm sure if its that simple though.

Ideally, the browser extension would be updated to allow user to enter/select the locale. However, having it as a "undocumented" feature is fine until "full" support is required.

Related Issue Link(s)

Release/Deployment notes

Summary by CodeRabbit

  • New Features
    • Added the ability to specify the installation profile and locale during the Drupal site setup process. Users can now set the installation locale through the DP_INSTALL_LOCALE environment variable, defaulting to "en" if not specified.

@codesandbox
Copy link

codesandbox bot commented Feb 22, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@ghost
Copy link

ghost commented Feb 22, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@tyler36 tyler36 force-pushed the tyler36/20230222_allow_locale branch from aa0f5be to bc56f15 Compare September 25, 2023 08:30
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 25, 2023

Walkthrough

The update introduces the ability to specify the locale for Drupal installation, defaulting to English if not defined. It involves setting up environment variables for the installation profile and locale, and modifying the installation command to utilize these variables. Additionally, the Docker image in the configuration is updated to the latest version, ensuring the use of the most recent environment for Drupal development.

Changes

Files Change Summary
.gitpod/.../drupalpod-setup.sh Added DP_INSTALL_PROFILE variable, modified ddev drush si command to include --locale option, and added DP_INSTALL_LOCALE variable.
.gitpod.yml Updated Docker image reference to drupalpod/drupalpod-gitpod-base:latest.

🐇✨
In the land of code and web,
Where Drupal pods doth ebb and flow,
A rabbit hopped, a path it wove,
Through locales far and scripts aglow.
"To the latest base," it whispered,
As the environment became bestowed,
With languages rich and diverse,
A global village, together sowed.
🌍🔧✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between f0a2503 and bc56f15.
Files selected for processing (1)
  • .gitpod/drupal/drupalpod-setup.sh (2 hunks)
Additional comments (Suppressed): 1
.gitpod/drupal/drupalpod-setup.sh (1)
  • 19-19: The environment variable DP_INSTALL_PROFILE is being set to 'en' which seems to be a locale code. This might be a typo and should probably be DP_INSTALL_LOCALE. Please verify.
-    export DP_INSTALL_PROFILE=en
+    export DP_INSTALL_LOCALE=en

.gitpod/drupal/drupalpod-setup.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between bc56f15 and 34dc9bd.
Files selected for processing (1)
  • .gitpod/drupal/drupalpod-setup.sh (2 hunks)
Additional comments (Suppressed): 1
.gitpod/drupal/drupalpod-setup.sh (1)
  • 321-321: The ddev drush si command has been updated to include the --locale option. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

.gitpod/drupal/drupalpod-setup.sh Outdated Show resolved Hide resolved
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 25, 2023

Rate Limit Exceeded

You have exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 29 minutes and 59 seconds before requesting another review.

To re-trigger a review, convert this PR to a draft and then mark it as ready for review again. Alternatively, you can push a new commit to this PR.

@tyler36 tyler36 force-pushed the tyler36/20230222_allow_locale branch from e5a864f to c6238e9 Compare March 1, 2024 01:48
@tyler36
Copy link
Contributor Author

tyler36 commented Mar 1, 2024

Reset / rebase on main

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d3c2d4a and c6238e9.
Files selected for processing (2)
  • .gitpod.yml (1 hunks)
  • .gitpod/drupal/drupalpod-setup/drupalpod-setup.sh (2 hunks)
Files skipped from review due to trivial changes (1)
  • .gitpod.yml
Additional comments: 1
.gitpod/drupal/drupalpod-setup/drupalpod-setup.sh (1)
  • 21-21: The addition of the DP_INSTALL_LOCALE environment variable initialization with a null default value is a good practice. It ensures that if the variable is not explicitly set, it won't cause any unexpected behavior in the script. This change aligns with the PR's objective to allow users to specify the installation locale.

@@ -136,8 +137,7 @@ GITMODULESEND
# ddev config auto updates settings.php and generates settings.ddev.php
ddev config --auto
# New site install
time ddev drush si -y --account-pass=admin --site-name="DrupalPod" "$DP_INSTALL_PROFILE"

time ddev drush si -y --account-pass=admin --site-name="DrupalPod" "$DP_INSTALL_PROFILE" --locale="${DP_INSTALL_LOCALE:-en}"
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modification to the ddev drush si command to include the --locale option, dynamically set to ${DP_INSTALL_LOCALE:-en}, effectively addresses the PR's objective. This change allows the installation locale to be specified via an environment variable, with a fallback to English if the variable is not set. It's a clear and concise way to implement this feature. However, it's important to ensure that all possible values for DP_INSTALL_LOCALE are valid Drupal locales. Additionally, consider documenting this environment variable and its usage for future users or developers.

Would you like assistance in documenting the DP_INSTALL_LOCALE variable usage in the project's README or developer documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please assist in documenting the DP_INSTALL_LOCALE variable usage in the project's README or developer documentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tyler36, based on the search results, it seems the most appropriate place to document the DP_INSTALL_LOCALE variable usage would be in the README.md file, as it's the central place for project documentation. Here's a draft for the documentation section:

### Setting the Installation Locale

DrupalPod allows you to specify the installation locale for Drupal via the `DP_INSTALL_LOCALE` environment variable. This can be particularly useful for users who wish to install Drupal in a language other than English.

To set the installation locale, define the `DP_INSTALL_LOCALE` environment variable in your environment. For example, to install Drupal in French, you would set the variable as follows:

```bash
export DP_INSTALL_LOCALE="fr"

If DP_INSTALL_LOCALE is not set, the installation will default to English (en). This feature ensures that DrupalPod can be easily customized to meet the needs of a diverse user base.


This section can be added to the `README.md` file under a suitable heading, such as "Configuration" or "Usage". Would you like this to be placed under a specific section, or do you have any modifications in mind?

<details>
<summary>Analysis chain</summary>



</details>

<details>
<summary>Scripts executed</summary>

The following scripts were executed for the analysis:



---

Script:
```shell
#!/bin/bash
# Search for README.md or other documentation files
fd -e md -e txt -e rst

Length of output: 171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant