Skip to content

Commit 756a515

Browse files
authored
[dotenv:init] Add translations. (#193)
1 parent 916e121 commit 756a515

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

translations/dotenv.init.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
description: 'Add support and required config to work with an .env file'
2+
messages:
3+
template-env: |
4+
This file is a "template" of which env vars need to be defined
5+
for your application, use only on development stages.
6+
Create real environment variables when deploying to production.
7+
load-from-env: |
8+
If not using real environment variables.
9+
Make sure you add the dependency using composer
10+
11+
Drupal 8.5 and up versions `composer require symfony/dotenv`
12+
if (file_exists(dirname(DRUPAL_ROOT) . '/.env')) {
13+
$dotenv = new \Symfony\Component\Dotenv\Dotenv(dirname(DRUPAL_ROOT));
14+
$dotenv->load();
15+
}
16+
17+
Drupal 8.4 and minor versions `composer require vlucas/phpdotenv`
18+
if (file_exists(dirname(DRUPAL_ROOT) . '/.env')) {
19+
$dotenv = new \Dotenv\Dotenv(dirname(DRUPAL_ROOT));
20+
$dotenv->load();
21+
}
22+
load-settings: |
23+
# Load key/value settings
24+
$settings_drupal = array_filter(
25+
$_SERVER,
26+
function($key) {
27+
return strpos($key, 'SETTINGS_') === 0;
28+
},
29+
ARRAY_FILTER_USE_KEY
30+
);
31+
32+
# Set key/value settings
33+
foreach ($settings_drupal as $name => $value) {
34+
if (substr($name, 0, 9) === 'SETTINGS_') {
35+
$key = strtolower(substr($name, 9));
36+
$settings['settings'][$key] = $value;
37+
}
38+
}

0 commit comments

Comments
 (0)