How-to
Website
Web app
Publish a page in each language
Have a search engine find your site in each of its languages. t() and setLocale translate a page in the browser, at one address, and a search engine indexes what that address's HTML says, which is the default locale. A site that wants each language found writes each page once per language, at an address of its own, and says how the pages are joined. This site is written in Arabic, with its home page in English at /en. The site's language, its address and a static build go in webfluent.app.json. Without meta.lang the site's pages are taken to be in English, and without meta.site_url there is no absolute address for the alternates:
Needs: the settings below in webfluent.app.json. It claims / and the name Home: paste it into a new project, or replace the starter's src/pages/Home.wf with it.
{
"build": { "ssg": true },
"meta": { "lang": "ar", "site_url": "https://example.com" }
}
Then the pages:
page Home(path: "/", title: "منذر عمر", description: "مهندس خلفيات.") {
Heading("مرحباً").h1
}
page HomeEn(path: "/en", title: "Monzer Omer", description: "Engineer.",
lang: "en", translates: Home) {
Heading("Hello").h1
}
How it works
lang:is the language the page is written in. A page without one is in the site's (meta.lang, ordefault_locale). The page is written<html lang="en">, withdir="rtl"for a language written right to left, and itsog:localeand its JSON-LD'sinLanguagesay the same. The router setslanganddiron<html>when it shows the page, and puts back the site's (or the locale the reader chose) on a page without one.translates:names the page this one is a translation of. Pages joined this way —HomeFrmay translateHometoo — each list all of them ashreflangalternates, at their own addresses and canonical to themselves, withx-defaultfor the one in the site's language, and each names the others' languages asog:locale:alternate.- A
:parampage's translation is matched by its parameters:/en/posts/:slugfor/posts/:slug, filled with the sameslug.
A translates: that names no page, or two translations of one page in one language, is R05.