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

Push i18n resources down to neo4j-arc library #37

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions docs/modules/ROOT/pages/neo4j-arc/i18n.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,17 @@ yarn add react-i18next i18next

=== Configuring i18next

Create a new file `i18n.js` beside our `App.tsx` containing following content:
Create a new file `i18n.ts` beside our `App.tsx` containing following content:

[source,javascript]
----
import i18n from 'i18next'
import { resources } from 'neo4j-arc/graph-visualization'
import { initReactI18next } from 'react-i18next'

const resources = {
en: {
translation: {
'graph summary':
'Displaying {{nodeCount}} nodes, {{relationshipCount}} relationships.',
'Relationship types': 'Relationship types',
'Node labels': 'Node labels'
}
},
zh: {
translation: {
'graph summary': '总计 {{nodeCount}} 个节点, {{relationshipCount}} 条边.',
'Relationship types': '关系类型',
'Node labels': '节点类型'
}
}
}

i18n.use(initReactI18next).init({
resources,
lng: 'en',
lng: 'zh',
interpolation: {
escapeValue: false
}
Expand All @@ -54,7 +37,8 @@ export default i18n

[NOTE]
====
* The file does not need to be named `i18n.js`, it can be any other filename. Just make sure it is imported accordingly.
* In the example above, we've configured i18n language to be Simplified Chinese
* The file does not need to be named `i18n.ts`, it can be any other filename. Just make sure it is imported accordingly.
* Those interested in the details above can refer to the
https://qubitpi.gitbook.io/react-i18next/guides/quick-start[react-i18next documentation]
====
Expand Down
30 changes: 0 additions & 30 deletions src/browser/i18n.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/browser/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import i18n from 'i18next'
import { resources } from 'neo4j-arc/graph-visualization'
import { initReactI18next } from 'react-i18next'

i18n.use(initReactI18next).init({
resources,
lng: 'zh',
interpolation: {
escapeValue: false
}
})

export default i18n
18 changes: 18 additions & 0 deletions src/neo4j-arc/graph-visualization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,21 @@ export {
REL_TYPE_UPDATE
} from './GraphVisualizer/Graph/GraphEventHandlerModel'
export type { GraphInteractionCallBack } from './GraphVisualizer/Graph/GraphEventHandlerModel'

export const resources = {
en: {
translation: {
'graph summary':
'Displaying {{nodeCount}} nodes, {{relationshipCount}} relationships.',
'Relationship types': 'Relationship types',
'Node labels': 'Node labels'
}
},
zh: {
translation: {
'graph summary': '总计 {{nodeCount}} 个节点, {{relationshipCount}} 条边.',
'Relationship types': '关系类型',
'Node labels': '节点类型'
}
}
}
2 changes: 1 addition & 1 deletion src/neo4j-arc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neo4j-devtools-arc",
"version": "0.0.65",
"version": "0.0.66",
"main": "dist/neo4j-arc.js",
"author": "Neo4j Inc.",
"license": "GPL-3.0",
Expand Down