Localization prop (i18n)
Learn to add internationalization to your Clerk components
Overview
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.
Using Localization
To use localization, you need to use the localization
prop as part of your ClerkProvider
and pass an object with your changes.
.env1
Predefined localizations
By default, Clerk uses the en-US
locale. Install the @clerk/localizations
package if you want to use one of the following predefined localizations:
frFR
for fr-FRdeDE
for de-DEenUS
for en-US (default)
Example: Use the frFR
localization
// You will need to install @clerk/localizations separatelyimport { frFR } from '@clerk/localizations';const App = () => {return (<ClerkProviderlocalization={frFR}>{...}</ClerkProvider>);}
For a complete list of modifiable properties and the English default strings, please refer to our Github repo.
Datetime localization
All datetime-related localization keys accept a date
parameter you can access and use with the usual double-bracket notation ({{ ... }}
). To further customize the final string, you can use the pipe operator (|
) to apply modifiers.
Currently, Clerk supports the following modifiers.
Name | Type | Description |
---|---|---|
weekday | string | Returns a string representing the weekday based on the - The locale to be used, as described in the Intl.DateTimeFormat specification, under the - The representation format to be used, as described in the Intl.DateTimeFormat specification, under the |
timeString | string | Returns a string representing the time based on the - The locale to be used, as described in the Intl.DateTimeFormat specification, under the |
numeric | string | Returns a formatted date string based on the - The locale to be used, as described in the Intl.DateTimeFormat specification, under the |
titleize | string | Returns the value on the left after transforming the first character to uppercase. Eg: |
For example, to translate the "Last Friday at 13.30"
string to French, you would use the following localization string:
1dates: {2previous6Days: "{{ date | weekday('fr-FR','long') | titleize }} dernier à {{ date | timeString('fr-FR') }}",3},
For more datetime examples, please refer to the dates key of our default English translation in our Github repo.