Skip to content

Commit 408ba7b

Browse files
AuspicusHannes VermeireblazeyonbaosullivanKyleAMathews
authored
feat(gatsby-source-drupal): Add toggleable multilingual support by prefixing nodes with their langcode (#26720)
* Determine languages from JSON:API content, use languages to fetch translations if 'translations' param provided * Sort configurable languages by weight to retrieve default * Fix lint issues * Allow for more than 50 configurable_language and language_content_settings entities * Default to und language if no langcode is provided by node * Add await to promises. Assign concats to the original variables. Fix deleteNode to use langcodes Fix for default languages url building * fix: extract href from link objects when fetching translation settings * refactor: use getHref in gatsby-source-drupal when possible * Update gatsby-node.js * Update normalize.js * Update normalize.js * Update gatsby-node.js * Update gatsby-node.js Avoid silently failing to fetch enabled language from Drupal * Update gatsby-node.js * Fix lint issues * Update utils.js * Update utils.js * Remove dependence on languageConfig from handleReferences * Fix lint * fix id creation * If translation is not enabled, always use for langcode * Catch and report error in multilingual not enabled in Drupal + ensure all langcode still * The default language JSONAPI root doesn't include its language code * Use url-join + check for non-default langauges * Use urlJoin more * update yarn.lock * update tests" * Remove dynamically fetching language config Instead set the config in the plugin options e.g.: ```js options: { translation: true, languageConfig: { defaultLanguage: `en`, enabledLanguages: [`en`, `fil`], translatableEntities: [`node--article`], } } ``` * remove import * Remove mistakenly committed file and ignore it * Add docs & just use existance of languageConfig to determine if translations are enabled or not * Fix check Co-authored-by: Hannes Vermeire <[email protected]> Co-authored-by: Błażej Owczarczyk <[email protected]> Co-authored-by: nbaosullivan <[email protected]> Co-authored-by: Kyle Mathews <[email protected]>
1 parent 757c81d commit 408ba7b

File tree

9 files changed

+256
-116
lines changed

9 files changed

+256
-116
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/gatsby-node.js
22
/normalize.js
33
/utils.js
4+
/plugin-options.js

packages/gatsby-source-drupal/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,29 @@ module.exports = {
292292
}
293293
```
294294

295+
## Translations
296+
297+
If you have translations or multilingual enabled on your Drupal site, you can opt-in to sourcing translations of entities. To do this, enable in your plugin's configuration the languages and entity types you'd like to source. E.g.
298+
299+
```javascript
300+
// In your gatsby-config.js
301+
module.exports = {
302+
plugins: [
303+
{
304+
resolve: `gatsby-source-drupal`,
305+
options: {
306+
baseUrl: `https://live-contentacms.pantheonsite.io/`,
307+
languageConfig: {
308+
defaultLanguage: `en`,
309+
enabledLanguages: [`en`, `fil`],
310+
translatableEntities: [`node--article`],
311+
},
312+
},
313+
},
314+
],
315+
}
316+
```
317+
295318
## Gatsby Preview (experimental)
296319

297320
You will need to have the Drupal module installed, more information on that here: https://www.drupal.org/project/gatsby

packages/gatsby-source-drupal/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"body-parser": "^1.19.0",
1414
"gatsby-source-filesystem": "^3.6.0-next.0",
1515
"lodash": "^4.17.21",
16-
"tiny-async-pool": "^1.2.0"
16+
"tiny-async-pool": "^1.2.0",
17+
"url-join": "^4.0.1"
1718
},
1819
"devDependencies": {
1920
"@babel/cli": "^7.12.1",
@@ -22,11 +23,7 @@
2223
"cross-env": "^7.0.3"
2324
},
2425
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-drupal#readme",
25-
"keywords": [
26-
"gatsby",
27-
"gatsby-plugin",
28-
"gatsby-source-plugin"
29-
],
26+
"keywords": ["gatsby", "gatsby-plugin", "gatsby-source-plugin"],
3027
"license": "MIT",
3128
"peerDependencies": {
3229
"gatsby": "^3.0.0-next.0"

0 commit comments

Comments
 (0)