Contributions are always welcome and there are multiple ways to join in from being a maintainer of a particular locale to submitting one-off improvement suggestions, big or small. Maintainers are tagged to help review automated pull-requests from AI and receive a token of appreciation from Sanity.
Before contributing, please read our code of conduct.
You can easily add suggestions to existing pull requests from AI and other contributors without checking out code, here is a quick demo:
Make sure you have Node.js version 18.3 or newer, as well as pnpm.
git clone [email protected]:sanity-io/locales.git
cd locales
pnpm install
pnpm run build
The strings are located in the src
folder of each plugin, where the file name represents the "namespace". Send a pull request if you have suggestions for improvements, and feel free to add yourself to the contributors array in locales/registry.ts. If you want to help review new translations, add yourself to the maintainers array instead, see below for more information. After doing your changes, run pnpm run reconcile and add the changes to version control.
Hooray! We appreciate your contribution and love seeing new locales added! Initially, you probably do not want to hand-translate every single string in the studio. Instead, simply request a new locale and we will run an initial AI translation for you. Once this is done, you can contribute edits/improvments to it and optinally be its maintainer.
Here is a full walkthrough of how we use AI to help us create language plugins and keep them updated, and how maintainers and contributors help
Should you want to manually translate or otherwise work directly with the source code, here are the steps involved:
- Create a new branch for your work (
git checkout -b feat/add-locale-<locale-id>
). - Edit
locales/registry.ts
and add a new entry to theregistry
array- The
id
property should be a BCP 47 language tag - Add your GitHub username to the
maintainers
andcontributors
arrays.
- The
- From the root of the repository, run
pnpm run reconcile
- Open up the newly created folder (matching the
id
property of the entry you put intolocales/registry.ts
) and inspect the contents.- The
src
folder will hold all the resources (strings) that need to be translated - one file per namespace. - Properties should have an
undefined
value, followed by a comment that holds the English (default) value. This makes it easier to spot what is missing translations.- Searching for
: undefined,
should give you a good indicator if any is missing. - You can also run
pnpm run check:missing --locale <locale>
to get a list of missing translations (if running with npm, you may need to runnpm run check:missing -- --locale <locale>
- note the double-dash).
- Searching for
- The
- Add and make changes to the translations! You can use the
pnpm run dev
command to start up a local studio with your changes. - Add your changes to git (
git add .
) and commit (git commit -m "feat(<locale-id>): add <locale name> locale"
). We use Conventional Commits for our commit messages.- Note: The reconciliation script will make changes to
pnpm-lock.yaml
,apps/studio
and possiblylocales/registry.ts
(if not sorted correctly). This is expected, and should be commited.
- Note: The reconciliation script will make changes to
- Push your changes to a fork and send a pull request!
Want to help maintain a plugin? Awesome! We appreciate your help! To get started, either request to be added as a maintainer, or add yourself as one by following these steps:
- Follow the Getting started instructions
- Add yourself to the
maintainers
array in thelocales/registry.ts
file for the language you have in mind. - Run
pnpm run reconcile
- it should update a few files, such aspackage.json
for the given locale. - Add the changes to git, commit the changes and push to a fork.
- Preferably the commit message (and PR name) should be something like "chore(): add @ as maintainer".
- Send a pull request!
If you run into build issues, you might want to try deleting node_modules
folders and reinstalling dependencies with pnpm install
.