Skip to content

Commit

Permalink
Add docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewjordan committed Jul 31, 2024
1 parent 05882aa commit 5a1fd66
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
1 change: 1 addition & 0 deletions pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"label": "Label",
"metadata": "Metadata",
"partOf": "PartOf",
"rendering": "Rendering",
"requiredStatement": "RequiredStatement",
"seeAlso": "SeeAlso",
"summary": "Summary",
Expand Down
70 changes: 63 additions & 7 deletions pages/docs/i18n.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,72 @@ title: i18n

# i18n

We welcome contributions to Clover in any language. If you would like to contribute to Clover in a language other than English, please follow the instructions below.
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 repository.
2. Create a new directory in the `i18n` directory with the name of the language you would like to contribute to.
3. Copy the `en` directory to the new directory.
4. Translate the files in the new directory.
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.

## Translation guidelines
### 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";

## Translation status
export default {
en,
fr,
"fr-CA": frCA,
};
```
5 changes: 4 additions & 1 deletion src/components/Slider/Header/ViewAll.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Homepage } from "src/components/Primitives";
import React from "react";
import { styled } from "src/styles/stitches.config";
import { useTranslation } from "react-i18next";

const ViewAllStyled = styled(Homepage, {
display: "flex",
Expand Down Expand Up @@ -31,7 +32,9 @@ const ViewAllStyled = styled(Homepage, {
});

const ViewAll = (props) => {
return <ViewAllStyled {...props}>View All</ViewAllStyled>;
const { t } = useTranslation();

return <ViewAllStyled {...props}>{t("commonViewAll")}</ViewAllStyled>;
};

export default ViewAll;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { InternationalString } from "@iiif/presentation-3";
import Menu from "src/components/Viewer/InformationPanel/Menu";
import { getLabel } from "src/hooks/use-iiif";
import { parse } from "node-webvtt";
import { useTranslation } from "react-i18next";

type AnnotationItemVTTProps = {
label: InternationalString | undefined;
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"commonSearch": "Search",
"commonSearchPlaceholder": "Search...",
"commonShare": "Share",
"commonViewAll": "View All",
"copyFailure": "Failed",
"copySuccess": "Copied",
"informationPanelTabs": "Select",
Expand Down

0 comments on commit 5a1fd66

Please sign in to comment.