Pre-Translated Pages

You can choose to ‘pre-translate’ pages while using Rosey. A ‘pre-translated’ page refers to a page that already exists for a locale, before Rosey builds any of your translated locales.

Rosey generates all of the pages for a translated locale from your default language’s pages and a JSON data file. However if Rosey detects that a page already exists at the path of a page it was going to generate, it will preserve the contents of that page - and any translations it contains - during the Rosey build step. For any page that already exists for a locale before the Rosey build step, Rosey will:

This is particularly useful for sites with pages that contain large sections of markdown body content that can be impractical to translate with a workflow using Rosey. You can use Rosey to translate any text elements in your layouts that repeat across multiple pages, like header, footer, or sidebar navigation text elements - while writing markdown in whatever language you like for the body content of your pages.

#An example

Say you have the following HTML pages in your site’s build output before generating your multilingual site with Rosey. The original pages are in English, and Rosey is using the default of en for the default language. A pre-translated page already exists for the French version of the homepage _site/fr/index.html, while the about page has no pre-translated equivalent in French.

_site
  index.html
  about
    index.html
  fr
    index.html

When you run the Rosey build command npx rosey build --source _site to generate your translated site, Rosey will detect there is already a translated version of the French homepage _site/fr/index.html. Instead of generating an entirely new page from the default language homepage _site/index.html, it will generate a page from the pre-translated page _site/fr/index.html, preserving the page’s contents, adding translations, and making translation specific adjustments to the DOM. The French about page _site_translated/fr/about/index.html will be generated from the English about page _site/about/index.html.

_site_translated
  index.html # The redirect page
  en
	  index.html # Original homepage
	  about
		  index.html # Original about page
  fr
	  index.html # French homepage - copied from the pre-translated version
	  about
		  index.html # French about page - generated by Rosey

The contents of the pre-translated /fr/index.html page will be the same as they were before Rosey built the translated site, but any elements that have data-rosey attributes, with corresponding translations in the Rosey locales files, will be translated by Rosey. The Rosey output of the pre-translated page will also add relevant metadata like the lang attribute, and alternate links to the different versions of the page for each locale - like a page generated by Rosey would typically have.