Skip to content

Commit

Permalink
Merge pull request #190 from samvera-labs/173-i18n-internationalization
Browse files Browse the repository at this point in the history
i18n Internationalization starter setup
  • Loading branch information
mathewjordan authored Jul 31, 2024
2 parents c70d01d + 4ff4279 commit 7e71769
Show file tree
Hide file tree
Showing 27 changed files with 2,697 additions and 2,278 deletions.
73 changes: 38 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,61 +75,64 @@
"@iiif/parser": "^1.1.2",
"@iiif/vault": "^0.9.22",
"@iiif/vault-helpers": "^0.10.0",
"@nulib/use-markdown": "^0.2.1",
"@radix-ui/react-aspect-ratio": "^1.0.3",
"@radix-ui/react-collapsible": "^1.0.3",
"@nulib/use-markdown": "^0.2.2",
"@radix-ui/react-aspect-ratio": "^1.1.0",
"@radix-ui/react-collapsible": "^1.1.0",
"@radix-ui/react-form": "^0.0.3",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-popover": "^1.1.1",
"@radix-ui/react-radio-group": "^1.2.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0",
"@stitches/react": "^1.2.8",
"flexsearch": "^0.7.43",
"hls.js": "^1.5.3",
"hls.js": "^1.5.13",
"i18next": "^23.12.2",
"i18next-browser-languagedetector": "^8.0.0",
"node-webvtt": "^1.9.4",
"openseadragon": "^4.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
"sanitize-html": "^2.11.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13",
"react-i18next": "^15.0.0",
"sanitize-html": "^2.13.0",
"swiper": "^9.4.1",
"uuid": "^9.0.1"
},
"devDependencies": {
"@iiif/presentation-3": "^1.1.3",
"@testing-library/jest-dom": "^6.4.1",
"@testing-library/react": "^14.2.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/flexsearch": "^0.7.6",
"@types/node": "20.11.16",
"@types/openseadragon": "^3.0.10",
"@types/react": "^18.2.51",
"@types/react-dom": "^18.2.18",
"@types/sanitize-html": "^2.9.5",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.2.2",
"@vitest/ui": "^1.2.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/sanitize-html": "^2.11.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^2.0.3",
"@vitest/ui": "^2.0.3",
"cross-fetch": "^4.0.0",
"dts-bundle-generator": "8.0.1",
"eslint-config-next": "14.1.0",
"eslint-config-prettier": "^9.1.0",
"execa": "^8.0.1",
"husky": "^8.0.3",
"jsdom": "^23.2.0",
"lint-staged": "^15.2.1",
"next": "^14.1.0",
"nextra": "^2.13.3",
"nextra-theme-docs": "^2.13.3",
"preact": "^10.19.3",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"terser": "^5.27.0",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.2.2"
"jsdom": "^24.1.0",
"lint-staged": "^15.2.7",
"next": "^14.2.5",
"nextra": "^2.13.4",
"nextra-theme-docs": "^2.13.4",
"preact": "^10.22.1",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"terser": "^5.31.3",
"typescript": "^5.5.3",
"vite": "^5.3.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.3"
},
"peerDependencies": {
"swiper": "^9.0.0"
Expand Down
8 changes: 7 additions & 1 deletion pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
"label": "Label",
"metadata": "Metadata",
"partOf": "PartOf",
"rendering": "Rendering",
"requiredStatement": "RequiredStatement",
"seeAlso": "SeeAlso",
"summary": "Summary",
"thumbnail": "Thumbnail"
"thumbnail": "Thumbnail",
"--contribute": {
"type": "separator",
"title": "Contribute"
},
"i18n": "i18n"
}
75 changes: 75 additions & 0 deletions pages/docs/i18n.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: i18n
---

# i18n

We welcome contributions to Clover IIIF in any language. If you would like to contribute to a language, please follow the instructions below.

```json filename="src/i18n/locales/en.json"
{
"commonClose": "Close",
"commonNext": "Next",
"commonPrevious": "Previous",
"commonSearch": "Search",
"commonSearchPlaceholder": "Search...",
"commonShare": "Share",
"commonViewAll": "View All",
...
}
```

## How to contribute

1. Fork the [Clover IIIF](https://github.com/samvera-labs/clover-iiif) repository.
2. Create a new file in the `src/i18n/locales` directory for the relative BCP 47 language code you would like to contribute towards, example `fr.json` for French.
3. Copy the `en.json` file as a template and translate the string values for each key.
4. Import the new language JSON file within the `src/i18n/locales/index.ts` file and include it in the default export.
5. Submit a pull request.

### Adding a new locale

Add a new file in the `src/i18n/locales` directory with the relative BCP 47 language code, example `fr.json` for French.

```json filename="src/i18n/locales/fr.json"
{
"commonClose": "Fermer",
"commonNext": "Suivant",
"commonPrevious": "Précédent",
"commonSearch": "Rechercher",
"commonSearchPlaceholder": "Rechercher...",
"commonShare": "Partager",
"commonViewAll": "Voir Tout",
...
}
```

```ts filename="src/i18n/locales/index.ts"
import en from "./en.json";
import fr from "./fr.json";

export default {
en,
fr,
};
```

### Language and Region subtags

If you would like to contribute a locale for a lanugage with a region subtag,
please use the `-` dash character to separate the language and region in the filename,
example `fr-CA.json` for Canadian French.

You will need to adjust the import statement in the `src/i18n/locales/index.ts` file to include the new locale.

```ts filename="src/i18n/locales/index.ts"
import en from "./en.json";
import fr from "./fr.json";
import frCA from "./fr-CA.json";

export default {
en,
fr,
"fr-CA": frCA,
};
```
Loading

0 comments on commit 7e71769

Please sign in to comment.