Languages
How Closeline runs in English and Arabic, right to left included, how to change any text, and what to change to add a language.
For the Full Stack package
The languages that ship
English and Arabic, in all three apps. Arabic lays the whole interface out right to left, with its own Arabic typefaces, and figures and dates stay in Latin digits in both languages. Money is always shown in US dollars.
| App | English | Arabic |
|---|---|---|
| Website | /en/… | /ar/… |
| CRM dashboard | /en/… | /ar/… |
| API | Accept-Language: en | Accept-Language: ar |
English is the default. Deal names, stage names, activity titles and role names are stored in both languages, as { en, ar }; one typed in a single language is kept under both until it is given its translation. The seed fills in the Arabic for the whole sample workspace.
How the language is chosen
- The language is the first part of the address. A path without one goes to
/en, or on the dashboard to the language the reader chose last. - The language switcher swaps that part of the address and keeps the page. In the dashboard, the Preferences tab of Settings keeps it on the account.
- The direction is set on the page before the first paint, so an Arabic page never flashes left to right.
- Both frontends send the page's language to the API, so its messages come back in the same language. The website's hand-overs to the dashboard keep the language too.
Change a text
Every visible word lives in messages/<namespace>/en.json and ar.json, in each frontend's folder. Change the value, keep the key, and change it in both files.
| App | Namespaces |
|---|---|
| Website | blog, contact, demo, errors, home, layout, legal, pricing, sampleData |
| CRM dashboard | ai-assistant, auth, common, dashboard (with a folder per page: activities, billing, contacts, deals, overview, pipeline, projects, reports, roles, settings, team, users and more), invitation, layouts, metadata |
- A key missing from
ar.jsonshows as a missing message on the Arabic side, so keep the two files in step. - Text inside
{curly}braces is filled in by the app, such as{count}or{name}. Keep those words as they are in both languages. - The dashboard's sidebar labels are messages too, under
nav.itemsinmessages/layouts/en.jsonandar.json, and its browser tab titles are inmessages/metadata/. - Validation messages come from the same files: every form builds its rules from the translated messages.
What the API translates
- When the API has a sentence for an error (a refused sign-in, too many attempts, sign-ups closed, maintenance mode), it comes back in the language of the
Accept-Languageheader.ar-SAcounts as Arabic; any language the API does not have falls back to English. - Other errors go out as codes such as
deal_version_conflictorloss_reason_required, and the dashboard shows its own sentence for each. - Its own texts are JSON files in
back-end/src/i18n/translations/en/andar/, one per area:admin,auth,common,mail,project,roles,settings,tasks,users. - The invitation, password-reset and billing emails are in
mail, written in the recipient's language: the one their account chose, otherwise the workspace's (for a reset, the language it was asked in), otherwise English. The link inside opens the dashboard in that language.
Add a language to the website
The two languages are written into a few files, so adding a third touches each of them. Paths are inside website/.
- Add the code to
localesinsrc/i18n/routing.tsandsrc/config/i18n.ts. - Copy every
messages/<namespace>/en.jsonto a file named after the new code, and translate the values. - If the language is written right to left, extend the direction check in
src/app/[locale]/layout.tsx, which only knowsar. - Add the language's name under
Common.language.namesin eachmessages/layout/file, so the switcher can offer it.
Add a language to the dashboard
- Add the code to
localesinsrc/config/i18n.tsandsrc/proxy.ts, and to the language choices insrc/components/LanguageSwitcher.tsxand the Preferences tab. - If it is written right to left, add it to
RTL_LOCALESinsrc/app/layout.tsx. - Copy every
messages/**/en.jsonto a file named after the new code, and translate the values. - Records keep an
{ en, ar }pair, so a third language in the data is a change to the API and its seed as well.
Add a language to the API
The API knows en and ar in back-end/src/i18n/i18n.service.ts, and the account preferences and the password-reset request accept those two. Add the new code there, copy src/i18n/translations/en/ to a folder named after it, and translate the files. Records store an { en, ar } pair, so a third language in the data is a change to those records and the seed.