https://github.com/pyramation/graphile-i18n
https://github.com/pyramation/graphile-i18n
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/pyramation/graphile-i18n
- Owner: pyramation
- License: mit
- Created: 2022-02-13T02:52:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-14T00:03:01.000Z (over 4 years ago)
- Last Synced: 2025-03-13T02:03:51.691Z (about 1 year ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphile-i18n [](https://travis-ci.com/pyramation/graphile-i18n)
```sh
npm install graphile-i18n
```
This [PostGraphile](http://postgraphile.org/) schema plugin was built to enable i18n language translation tables.
## Usage
1. Create a language translation table
2. Add smart comments
3. Register plugin with postgraphile
## language table
Add language table with `lang_code` field and a smart comment for `i18n`:
```sql
CREATE TABLE app_public.projects (
id serial PRIMARY KEY,
name citext,
description citext
);
COMMENT ON TABLE app_public.projects IS E'@i18n project_language_variations';
CREATE TABLE app_public.project_language_variations (
id serial PRIMARY KEY,
project_id int NOT NULL REFERENCES app_public.projects(id),
lang_code citext,
name citext,
description citext,
UNIQUE(project_id, lang_code)
);
```
## Register Plugin
```js
app.use(
postgraphile(connectionStr, schemas, {
appendPlugins: [
LangPlugin
],
graphileBuildOptions: {
langPluginDefaultLanguages: ['en']
}
})
);
```
## testing
```
createdb test_database
psql test_database < sql/roles.sql
psql test_database < sql/test.sql
yarn test
```