Internationalization
Files: src/config/language.json, src/config/config.toml, src/i18n/, src/config/menu.<language>.json, src/content/**/<language>/ · Skill level: Beginner
Lotline ships in English (the default, at /), French (at /fr/) and Arabic (at /ar/), with full right-to-left support on Arabic pages. Every page, listing, menu and label exists in all three. You can keep them, keep only your default language, or add another one. For how right-to-left works, see RTL & Arabic.
What Makes Up A Language
| Part | Files |
|---|---|
| The language itself | an entry in src/config/language.json |
| Page, listing and section text | a folder per language in every content folder, such as src/content/properties/french/ and src/content/sections/arabic/ |
| Interface text | src/i18n/<language>.json, such as fr.json: buttons, labels, filter names, form messages, units, and the tagline and description for search |
| Menus | src/config/menu.<language>.json, such as menu.ar.json |
[ { "languageName": "En", "languageCode": "en", "contentDir": "english", "dir": "ltr", "ogLocale": "en_US", "dateLocale": "en-US", "weight": 1 }, { "languageName": "Fr", "languageCode": "fr", "contentDir": "french", "dir": "ltr", "ogLocale": "fr_FR", "dateLocale": "fr-FR", "weight": 2 }, { "languageName": "العربية", "languageCode": "ar", "contentDir": "arabic", "dir": "rtl", "ogLocale": "ar_SA", "dateLocale": "ar", "weight": 3 }]| Key | What it does |
|---|---|
languageName | The label on the language links |
languageCode | The URL prefix and the file suffix (fr.json, menu.fr.json) |
contentDir | The folder name inside each content folder |
dir | ltr or rtl. This one value sets the direction of the page |
ogLocale | The language of social previews |
dateLocale | The format of dates and numbers |
weight | The order of the language links |
Visitors switch language with the links in the footer and in the phone menu. A link goes to the same page in the other language.
Your agency details stay in one place for every language: [business] in config.toml (name, phone, email, address, hours). Don’t type them into translations.
Language Settings
[settings.multilingual] enable = true defaultLanguage = "en" disableLanguages = [""] # for example ["fr"] to switch French off without deleting it showDefaultLangInUrl = false # true: English at /en/ instead of /Restart npm run dev after you change these values.
Translate Or Edit Text
- Page and listing text: edit the file with the same name in the language’s folder, for example
src/content/properties/french/elm-hill-modern-villa.md. Keep the keys and structure the same as in English and translate the values only. Numbers such asprice,bedsandareastay the same in every language. - Interface text: edit the same key in the language’s file, for example
navigation.buttonLabel(“Book a valuation”) insrc/i18n/fr.json. - Menus: each
src/config/menu.<language>.jsonkeeps the same structure asmenu.en.json: the same items, in the same order, with the sameurl. Translate the labels. The featured card in the Properties menu has itstitleandpricetyped out, so update them in every language. - Links inside text: a Markdown link in a translated file carries its language, such as
[Contact](/fr/contact/). Menu and button URLs don’t need it. - Search wording: the tagline, description and keywords of each language are
seo.tagline,seo.siteDescriptionandseo.keywordsin itssrc/i18n/<language>.json. See SEO & AI Visibility.
Check Your Translations
npm run check-i18nIt also runs as part of npm run astro-check, and it fails when:
- a key in the default language’s
src/i18n/file is missing from another language file, or the other way round, - a key in that file is no longer read by any code,
- a menu file differs from the default language’s menu in structure (item count,
url,source), - a content file in the default language’s folder has no copy in another language folder, or the other way round.
It warns about empty strings and strings still equal to the English ones. Words that stay the same in every language on purpose (such as “villa” or “ChatGPT”) are listed in scripts/check-i18n.mjs.
Prices, Areas And Dates
You never write a formatted price in content. Each listing has a plain number, and the theme formats it for the page language: $1,240 in English becomes 1 240 $US in French. Arabic pages keep the $1,240 form, written left to right, so the symbol and the digits never swap ends. Every language uses Western digits.
[listings] currency = "USD" # ISO 4217 code of every listing price, development "from" price and rent locale = "" # empty: each language's dateLocale from language.json areaUnit = "sq ft"
[settings.currency] code = "USD" # salaries on job pages and the currency in structured data display = "symbol" # how salaries show: symbol ($ / $US) | narrowSymbol ($ in every language) | code (USD)Set both currency and code to your own currency ("EUR", "GBP", "CAD"). The area unit is translated too: "sq ft" shows as pi² in French and قدم² in Arabic, and "m²" stays m². Those words are listings.units in each src/i18n/<language>.json. See Listing Search & Filters.
Remove A Language
To turn one language off, add its code to disableLanguages in [settings.multilingual], for example ["fr"]. Its files stay in the project, and you can turn it back on later. Restart npm run dev.
To keep only your default language:
- Save a git commit or a copy of the folder, because the next steps delete files.
- Set
enable = falsein[settings.multilingual]ofsrc/config/config.toml. - Run
npm run devonce, then stop it. - Run
npm run remove-multilingual. It deletes the content folders, the menu file and thesrc/i18n/file of every language except the default one, French and Arabic included, and rewriteslanguage.json.
Add A Language
Example: German, code de, folder german.
-
Run the language script:
Terminal window npm run generate-multilingual-content -- --lang de --name Deutsch --dir-name german --locale de-DE --og de_DEFor a right-to-left language, add
--dir rtl. The script adds the language tolanguage.jsonand copies your default language’s content folders, menu file andsrc/i18n/file. It keeps files that already exist unless you add--force. -
Translate the new
german/content folders,src/config/menu.de.jsonandsrc/i18n/de.json. In the copied files, add the language to Markdown links, such as[Contact](/de/contact/). -
On Netlify, add a
/de/*block tonetlify.toml, copied from the/fr/*one, so a missing German page shows the German 404 page. -
If the language’s alphabet needs its own font, add one to
src/config/fonts.json, using the Arabic font entry as your model. -
Restart the dev server, then run
npm run check-i18nand fix what it lists.
Do It With AI
Add [LANGUAGE] (code [CODE], folder [FOLDER]) to my Lotline site. Follow "Add or remove a language"in SKILLS.md: run npm run generate-multilingual-content with the flags it lists, then translate thenew content folders, src/config/menu.[CODE].json and src/i18n/[CODE].json. Add the language prefixto Markdown links in the new files. Keep every price, bedroom count and floor area unchanged.Then run npm run check-i18n and fix what it lists.Translate my changes to every other language: for every file I changed in src/content/**/english/today, update the file with the same name in each other language folder (same keys, translatedvalues, numbers unchanged), and add any new key from src/i18n/en.json to the other files insrc/i18n/. Then run npm run check-i18n.