Skip to content

Commit 085a5ac

Browse files
committed
docs(readme): elaborate on graphql integration
1 parent 947c252 commit 085a5ac

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ When you create pages programmatically with `createPage()` by default the page w
8585
- `referTranslations: string[]`: Refers translations for given locales.
8686
- `adjustPath: boolean`: Add locale prefix and replaces slugs.
8787

88+
### GraphQL data layer integration
89+
90+
All translation messages are sourced to Gatsbys GraphQL data layer with `translation` and `allTranslation`. Here is an example GraphQL query:
91+
92+
```typescript
93+
export const query = graphql`
94+
query SomePage($locale: String) {
95+
pageTitle: translation(locale: { eq: $locale }, key: { eq: "page.some.title" }) {
96+
message
97+
}
98+
pageDescription: translation(locale: { eq: $locale }, key: { eq: "page.some.description" }) {
99+
message
100+
}
101+
}
102+
`;
103+
```
104+
88105
## Development
89106

90107
1. **Clone** the project

0 commit comments

Comments
 (0)