Skip to content

Commit bba2523

Browse files
committed
add locale register to docs
1 parent efc36ba commit bba2523

File tree

13 files changed

+670
-87
lines changed

13 files changed

+670
-87
lines changed

package-lock.json

Lines changed: 492 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"pages:build": "rimraf ./pages/docs && npm run generic:build && bash ./scripts/buildPages.sh",
3838
"pages:build:serve": "http-server pages -o index.html",
3939
"clean": "nx reset && rimraf --glob packages/**/{.cache,dist,docs} && rimraf --glob {.cache,dist} && node ./scripts/clean",
40-
"docs:afm": "node ./scripts/makeDocs afm",
41-
"docs:generic": "node ./scripts/makeDocs generic",
42-
"docs:meldemichel": "node ./scripts/makeDocs meldemichel && npm run meldemichel:build && cp -r ./packages/clients/meldemichel/dist ./packages/clients/meldemichel/example ./packages/clients/meldemichel/docs",
43-
"docs:snowbox": "node ./scripts/makeDocs snowbox",
44-
"docs:textLocator": "node ./scripts/makeDocs textLocator && npm run textLocator:build && cp -r ./packages/clients/textLocator/dist ./packages/clients/textLocator/docs",
40+
"docs:afm": "npx tsx ./scripts/makeDocs afm",
41+
"docs:generic": "npx tsx ./scripts/makeDocs generic",
42+
"docs:meldemichel": "npx tsx ./scripts/makeDocs meldemichel && npm run meldemichel:build && cp -r ./packages/clients/meldemichel/dist ./packages/clients/meldemichel/example ./packages/clients/meldemichel/docs",
43+
"docs:snowbox": "npx tsx ./scripts/makeDocs snowbox",
44+
"docs:textLocator": "npx tsx ./scripts/makeDocs textLocator && npm run textLocator:build && cp -r ./packages/clients/textLocator/dist ./packages/clients/textLocator/docs",
4545
"lint": "npx eslint . --cache --ext .js,.ts,.vue",
4646
"lint:ci": "npx eslint . --ext .js,.ts,.vue",
4747
"lint:fix": "npx eslint . --fix --cache --ext .js,.ts,.vue",
@@ -102,10 +102,10 @@
102102
"ts-jest": "^29.0.5",
103103
"ts-node": "^10.9.1",
104104
"tslib": "^2.3.0",
105+
"tsx": "^4.19.2",
105106
"typescript": "^5.6.2",
106107
"vite": "^5.4.8",
107108
"vite-plugin-commonjs": "^0.6.2",
108109
"vue-template-compiler": "^2.7.16"
109-
},
110-
"dependencies": {}
110+
}
111111
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const locales = [
1+
const language = [
22
{
33
type: 'de',
44
resources: {
@@ -44,4 +44,4 @@ const locales = [
4444
},
4545
]
4646

47-
export default locales
47+
export default language

packages/clients/dish/src/mapConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
dishBaseUrl,
88
// servicePrefix, s.u.
99
} from './services'
10-
import locales from './locales'
10+
import locales from './language'
1111

1212
const shBlue = '#003064'
1313
const shWhite = '#FFFFFF'
File renamed without changes.

packages/clients/textLocator/src/mapConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MapConfig } from '@polar/lib-custom-types'
2-
import locales from './locales'
2+
import locales from './language'
33
import {
44
openStreetMap,
55
openSeaMap,

packages/core/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ const languageOptions: LanguageOption[] = [
174174
]
175175
```
176176

177-
To figure out the name of the locales to override, inspect the matching plugin in GitHub's file browser. In `packages/plugins`, open the plugin you desire to override. Each plugin's `src` folder contains a `language.ts` listing all used locale keys with appropriate nesting.
177+
To figure out the name of overridable locales, inspect the documentation of your client; [for example, this is the documentation page of the snowbox](https://dataport.github.io/polar/docs/snowbox/client-snowbox.html). All child documents with locales feature a table of default translations at the end, and some clients bring their own locales and pre-existing overrides.
178+
179+
When reading the locale tables, please mind that the dot notation (`a.b.c | value`) has to be written as separate keys in nested objects as seen in the example above (`{a: {b: {c: "value"}}}`).
178180

179181
##### mapConfiguration.extendedMasterportalapiMarkers
180182

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@ import i18next, { init, use } from 'i18next'
22
import LanguageDetector from 'i18next-browser-languagedetector'
33
import Vue from 'vue'
44
import VueI18Next from 'i18next-vue'
5-
import de from './locales/de'
6-
import en from './locales/en'
5+
import language from '../language'
76

87
use(LanguageDetector)
98
Vue.use(VueI18Next, { i18next })
109

10+
const supportedLngs = language.map(({ type }) => type)
11+
1112
/**
1213
* @param initialLanguage - If given, the initial language set in the mapConfiguration.
1314
*/
1415
export default (initialLanguage?: string) =>
1516
init({
16-
resources: { de, en },
17+
resources: language.reduce((accumulator, { type, resources }) => {
18+
accumulator[type] = resources
19+
return accumulator
20+
}, {}),
1721
detection: {
1822
lookupQuerystring: 'lng',
1923
order: ['querystring', 'navigator', 'htmlTag'],
2024
},
2125
load: 'languageOnly',
22-
fallbackLng: 'de',
26+
fallbackLng: supportedLngs[0],
2327
fallbackNS: 'common',
2428
ns: ['common'],
25-
supportedLngs: ['de', 'en'],
29+
supportedLngs,
2630
...(initialLanguage ? { lng: initialLanguage } : {}),
2731
})
2832
.then(() => {

packages/core/src/language.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { LanguageOption } from '@polar/lib-custom-types'
2+
3+
// first type will be used as fallback language
4+
const language: LanguageOption[] = [
5+
{
6+
type: 'de',
7+
resources: {
8+
common: {
9+
canvas: {
10+
label: 'Kartenanwendung',
11+
},
12+
error: {
13+
serviceUnavailable:
14+
'Der Kartendienst "{{serviceName}}" (ID: {{serviceId}}) ist derzeit nicht verfügbar. Dies kann die Funktionalität der Karte einschränken.',
15+
},
16+
overlay: {
17+
noControlOnZoom: 'Verwenden Sie Strg+Scrollen zum Zoomen der Karte',
18+
noCommandOnZoom:
19+
'Verwenden Sie Command ⌘ + Scrollen zum Zoomen der Karte',
20+
oneFingerPan:
21+
'Verwenden Sie mindestens zwei Finger zum Verschieben der Karte',
22+
},
23+
},
24+
},
25+
},
26+
{
27+
type: 'en',
28+
resources: {
29+
common: {
30+
canvas: {
31+
label: 'Map application',
32+
},
33+
error: {
34+
serviceUnavailable:
35+
'Service "{{serviceName}}" (ID: {{serviceId}}) is unavailable. This may limit the map\'s functionality.',
36+
},
37+
overlay: {
38+
noControlOnZoom: 'Use Ctrl+Mousewheel to zoom into the map',
39+
noCommandOnZoom: 'Use Command ⌘ + Mousewheel to zoom into the map',
40+
oneFingerPan: 'Use at least two fingers to pan the map',
41+
},
42+
},
43+
},
44+
},
45+
]
46+
47+
export default language

packages/core/src/language/locales/de.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)