Skip to content

Commit e6b52ae

Browse files
authored
chore(repo): Improve main & localizations README (clerk#1747)
1 parent 4327b91 commit e6b52ae

4 files changed

Lines changed: 124 additions & 43 deletions

File tree

.changeset/big-socks-perform.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/localizations": patch
3+
---
4+
5+
Improve README by adding instructions on how to add/edit localizations

README.md

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
</a>
88
<br />
99
</p>
10+
<h1 align="center">
11+
Official Clerk JavaScript SDKs
12+
</h1>
13+
<p align="center">
14+
<strong>
15+
Clerk helps developers build user management. We provide streamlined user experiences for your users to sign up, sign in, and manage their profile.
16+
</strong>
17+
</p>
1018

11-
# Official Clerk JavaScript SDKs
12-
13-
This repository contains all the Clerk JavaScript SDKs under the `@clerk/` namespace. Visit [https://clerk.com](https://clerk.com) to signup for an account.
19+
This repository contains all the Clerk JavaScript SDKs under the `@clerk` namespace. Visit [clerk.com](https://clerk.com) to signup for an account.
1420

1521
[![chat on Discord](https://img.shields.io/discord/856971667393609759.svg?logo=discord)](https://clerk.com/discord)
1622
[![documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://clerk.com/docs)
@@ -24,53 +30,41 @@ Would you like to work on Open Source software and help maintain this repository
2430

2531
---
2632

27-
## Documentation and Usage
33+
## 🚀 Get Started with Clerk
2834

29-
For how to get started with Clerk, you can refer to the official [documentation page](https://clerk.com/docs).
35+
1. [Sign up for an account](https://dashboard.clerk.com/sign-up?utm_source=github&utm_medium=clerk_js_repo_readme)
36+
1. Create an application in your Clerk dashboard
37+
1. Spin up a new codebase with one of the [quickstart guides](https://clerk.com/docs/quickstarts/overview?utm_source=github&utm_medium=clerk_js_repo_readme)
3038

31-
For JavaScript environments/platforms that Clerk supports, there should be a specific package corresponding to the respective technology.
39+
This repository contains the SDKs for environment/platforms that Clerk supports. For example, if you want to use Clerk with Node.js you can install:
3240

3341
```sh
3442
npm install @clerk/clerk-sdk-node
3543
# or
3644
yarn add @clerk/clerk-sdk-node
45+
# or
46+
pnpm add @clerk/clerk-sdk-node
3747
```
3848

39-
## Packages
49+
## 🎓 Learning Clerk
4050

41-
For package specific details on installation, architecture and usage usage, you can refer to the package's README file.
51+
Clerk's full documentation is available at [clerk.com/docs](https://clerk.com/docs?utm_source=github&utm_medium=clerk_js_repo_readme).
4252

43-
- [`@clerk/backend`](./packages/backend): Functionalities regarded as "core" for Clerk to operate with. _Authentication resolution, API Resources etc._
44-
- [`@clerk/clerk-expo`](./packages/expo) Clerk package for the Expo universal app framework.
45-
- [`@clerk/clerk-js`](./packages/clerk-js): Core JavaScript implementation used by Clerk in the browser.
46-
- [`@clerk/clerk-react`](./packages/react) Clerk package for React applications.
47-
- [`@clerk/clerk-sdk-node`](./packages/sdk-node): SDK for native Node.js environment and frameworks.
48-
- [`@clerk/fastify`](./packages/fastify): Clerk package for Fastify.
49-
- [`@clerk/chrome-extension`](./packages/chrome-extension): Clerk package for Chrome extensions.
50-
- [`@clerk/nextjs`](./packages/nextjs): Clerk package for Next.js.
51-
- [`@clerk/remix`](./packages/remix): Clerk package for Remix.
52-
- [`@clerk/types`](./packages/types) Main TypeScript typings for Clerk libraries.
53-
- ...
53+
- **We recommend starting with the [Quickstart guides](https://clerk.com/docs/quickstarts/overview).** It'll enable you to quickly add Clerk to your application. If you're starting a new project and are not sure what to pick, use [Next.js](https://nextjs.org/docs/getting-started/installation) and [@clerk/nextjs](https://clerk.com/docs/quickstarts/nextjs).
54+
- **To learn more about Clerk's components and features, checkout the rest of the [Clerk documentation](https://clerk.com/docs?utm_source=github&utm_medium=clerk_js_repo_readme).** You'll be able to e.g. browse the [component reference](https://clerk.com/docs/components/overview?utm_source=github&utm_medium=clerk_js_repo_readme) page.
5455

55-
Additionally there are packages which act as shared utilities or building blocks.
56+
## 🚢 Release Notes
5657

57-
## Setup
58+
Curious what we shipped recently? You can browse the [GitHub Releases](https://github.com/clerkinc/javascript/releases) page or look at the individual `CHANGELOG.md` files inside each package (e.g. [`clerk-js CHANGELOG`](https://github.com/clerkinc/javascript/blob/main/packages/clerk-js/CHANGELOG.md)).
5859

59-
- Clone the repository.
60-
- `npm install`.
61-
- `npm run build`.
60+
## 🤝 How to Contribute
6261

63-
\* See the [docs folder](./docs) for additional repository documentation.
62+
We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerkinc/javascript/blob/main/docs/CONTRIBUTING.md). We'd love to have you as part of the Clerk community!
6463

65-
## Cleanup
64+
It'll show you how to make changes to the SDKs, open pull requests, or submitting issues. If you want to add or edit localizations (e.g. how a button text is translated to your language), you can check out the [`localizations` README](./packages/localizations/README.md).
6665

67-
To clean existing builds and installed dependencies of the monorepo and setup again, run `npm run nuke`.
66+
## 📝 License
6867

69-
## How to add a new localization key
68+
This project is licensed under the **MIT license**.
7069

71-
- Add the key types to the types [package](./packages/types/src/localization.ts).
72-
- Add the corresponding localization values for every supported language in the [localizations package](./packages/localizations/)
73-
- Replace the plain string (if there is one) with the localization value like so:
74-
`<Text>Role</Text>`
75-
becomes
76-
`<Text localizationKey={localizationKeys('formFieldLabel__role')} />`
70+
See [LICENSE](https://github.com/clerkinc/javascript/blob/main/LICENCE.md) for more information.

docs/CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Please note we have a [code of conduct](https://github.com/clerkinc/javascript/b
1818
- [What is the difference between a commit message, a PR description and a changeset description?](#what-is-the-difference-between-a-commit-message-a-pr-description-and-a-changeset-description)
1919
- [Notes on Pull Requests](#notes-on-pull-requests)
2020
- [Issues and feature requests](#issues-and-feature-requests)
21+
- [Localizations](#localizations)
2122
- [Publishing packages](#publishing-packages)
2223
- [License](#license)
2324

@@ -35,6 +36,16 @@ The current monorepo setup is based on:
3536
- [GitHub Actions](https://docs.github.com/en/actions), used for quality checks and automated release orchestration.
3637
- [Yalc](https://github.com/wclr/yalc), used for to publish packages locally and test them in other local projects.
3738

39+
All packages of the monorepo are inside [packages](../packages). For package specific details on installation, architecture and usage, you can refer to the package's README file.
40+
41+
- [`@clerk/backend`](../packages/backend): Functionalities regarded as "core" for Clerk to operate with. _Authentication resolution, API Resources etc._
42+
- [`@clerk/clerk-js`](../packages/clerk-js): Core JavaScript implementation used by Clerk in the browser.
43+
- [`@clerk/clerk-react`](../packages/react) Clerk package for React applications.
44+
- [`@clerk/types`](../packages/types): Main TypeScript typings for Clerk libraries.
45+
- Browse [packages](../packages) to see more
46+
47+
Additionally there are packages which act as shared utilities or building blocks.
48+
3849
### Prerequisites
3950

4051
Have a node version installed that is equal or higher than the one defined in `.nvmrc`
@@ -154,6 +165,10 @@ Issues that have the label `needs-triage` have been seen by our team and are que
154165

155166
If you are a paying Clerk customer looking for support, please reach out directly to our support team by heading to https://www.clerk.com, clicking the chat bubble in the bottom right corner, and selecting "contact support".
156167

168+
## Localizations
169+
170+
If you want to add or edit localizations (e.g. how a button text is translated to your language), you can check out the [`localizations` README](../packages/localizations/README.md).
171+
157172
## Publishing packages
158173

159174
_Note: Only core maintainers can publish packages._

packages/localizations/README.md

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030

3131
## Overview
3232

33-
`@clerk/localizations` contains localized strings for applications using Clerk.
33+
Clerk offers the ability to override the strings for all of the elements in each of the Clerk Components. This allows you to provide localization for your users or change the wording to suit your brand.
34+
35+
`@clerk/localizations` contains localized strings for applications using Clerk. If you found a typo, inaccuracies, or want to contribute a new language, please submit a PR and follow the [contributing guide](#contributing).
3436

3537
## Getting Started
3638

@@ -52,22 +54,43 @@ npm run build
5254

5355
## Usage
5456

57+
`@clerk/localizations` contains predefined localizations you can use:
58+
5559
```javascript
56-
import { ClerkProvider } from '@clerk/nextjs';
60+
import React from 'react';
61+
import { ClerkProvider } from '@clerk/clerk-react';
5762
import { frFR } from '@clerk/localizations';
5863

59-
function MyApp({ Component, pageProps }) {
64+
function App() {
65+
return (
66+
<ClerkProvider localization={frFR}>
67+
<div>Hello from clerk</div>
68+
</ClerkProvider>
69+
);
70+
}
71+
72+
export default App;
73+
```
74+
75+
You can also provide your own localization:
76+
77+
```javascript
78+
import React from 'react';
79+
import { ClerkProvider } from '@clerk/clerk-react';
80+
81+
const localization = {
82+
socialButtonsBlockButton: 'Sign In with {{provider|titleize}}',
83+
};
84+
85+
function App() {
6086
return (
61-
<ClerkProvider
62-
localization={frFR}
63-
{...pageProps}
64-
>
65-
<Component {...pageProps} />
87+
<ClerkProvider localization={localization}>
88+
<div>Hello from clerk</div>
6689
</ClerkProvider>
6790
);
6891
}
6992

70-
export default MyApp;
93+
export default App;
7194
```
7295

7396
## Support
@@ -82,6 +105,50 @@ You can get in touch with us in any of the following ways:
82105

83106
We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerkinc/javascript/blob/main/docs/CONTRIBUTING.md).
84107

108+
### Adding a new localization key
109+
110+
1. Open the [`types/src/localization.ts`](https://github.com/clerkinc/javascript/blob/main/packages/types/src/localization.ts) file to add a new key to the `_LocalizationResource` type.
111+
112+
Naming things is hard, so try these things first: Has the component that should contain the new key already other localizations? If yes, see how they are named and if you could follow that pattern. For example, the `<SignIn />` component has keys with `signIn.start.title`, then I'd make sense to follow the `signIn.` pattern. If you're not sure, take your best guess and the maintainers will comment on the PR!
113+
114+
An exception to that are any errors that might be returned from the Frontend API. They need to go into the `unstable__errors` object inside each localization.
115+
116+
1. Run `npm build` to compile `types` with your new key
117+
118+
1. Open the [`localizations/src/en-US.ts`](https://github.com/clerkinc/javascript/blob/main/packages/localizations/src/en-US.ts) file and add your new key to the object. `en-US` is the default language. If you feel comfortable adding your message in another language than English, feel free to also edit other files.
119+
120+
1. Use the new localization key inside the component. There are two ways:
121+
122+
- The string is inside a component like `<Text>`:
123+
124+
```diff
125+
- <Text>Role</Text>
126+
+ <Text localizationKey={localizationKeys('formFieldLabel__role')} />
127+
```
128+
129+
- The string is used in a function call:
130+
131+
```diff
132+
+ const { t } = useLocalizations();
133+
134+
- card.setError('Some Error')
135+
+ card.setError(t(localizationKeys('some_error')))
136+
```
137+
138+
You'll need to import `localizationKeys` and `useLocalizations` when using them.
139+
140+
### Updating a localization key
141+
142+
1. Open the [`localizations/src/en-US.ts`](https://github.com/clerkinc/javascript/blob/main/packages/localizations/src/en-US.ts) file and search for the text you want to update.
143+
144+
1. Update the text inside `en-US`. If possible, also update other languages.
145+
146+
### Adding a new localization language
147+
148+
1. Create a new file that follows the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format
149+
150+
1. Copy the contents of the `en-US.ts` file and translate all keys where necessary. Empty strings can stay empty. You don't need to translate things word by word, adjust where necessary as long as the same meaning is conveyed.
151+
85152
## Security
86153

87154
`@clerk/localizations` follows good practices of security, but 100% security cannot be assured.

0 commit comments

Comments
 (0)