🌞
.
उपलब्ध नहीं है
इस दस्तावेज़ का अभी तक ⁨Hindi⁩ में अनुवाद नहीं हुआ है। आप ⁨English⁩ संस्करण देख रहे हैं।
Step by Step guide to setup translation with fpm

FPM provides a first class support for translations of the documents. A particular package can either be a translation or have translations pointing to other packages. At the build time, we process your translations and generate metadata for each and every page in the corresponding package to ensure you as the project maintainer, have a complete idea about what is going on in your project.

A translation package keeps track of your documents and helps you keep the documents in sync with each other.

A translation is a two way agreement between two packages.

Prerequisites

You’ll need to set up two fpm packages to enable translation across the two of them.

For this example, we’ll be using foo.com and bar.com where bar.com is the translation of foo.com

foo.com = master bar.com = translation

Please familiarize yourself with our Translation Philosphy to get acquainted with the terminologies used in the document

Setting up the master package
The master package needs to specify the language it’s targetting. At the very core, this is the bare minimum setting you’ll require to enable the translations for your master package
foo.com/FPM.ftd
-- import: fpm

-- fpm.package: foo.com
language: English
Let’s create a few documents in this package which we’re supposed to be translated.
$/foo.com/> touch example{01..05}.ftd
fpm sync
fpm sync command allows you to synchronize your changes and create a snapshot of the package at the current timestamp in the .history folder in the root directory of your package.
fpm sync output
$ /foo.com/> fpm sync

Repo for foo.com is github, directly syncing with .history.
FPM.ftd
example01.ftd
example02.ftd
example03.ftd
example04.ftd
example05.ftd
We can now push the code and deploy our package.
Setting up the translation package
The translation package must specify the translation-of package. Specifying this marks the current package as the translation-of of another package.
bar.com/FPM.ftd
-- import: fpm

-- fpm.package: bar.com
translation-of: foo.com
language: hi
Translate documents
Let’s start by creating a few counter part documents in the bar.com package.
Translation documents
$/bar.com/> touch example{01..03}.ftd
Translation status
$/bar.com/> fpm translation-status

Never marked: FPM.ftd
Never marked: example01.md
Never marked: example02.ftd
Never marked: example03.ftd
Missing: example04.ftd
Missing: example05.ftd
The fpm translation-status command will give you a complete overview of the documents in the current package.
fpm mark-upto-date
You can invoke this command along with a module path to mark that particular document as upto date in the translation tree. Doing so will create a track of your document at the current timestamp.
Mark up to date
$/bar.com/> fpm mark-upto-date example01.ftd

example01.ftd is now marked upto date

\$/bar.com/> fpm mark-upto-date example02.ftd

example02.ftd is now marked upto date

\$/bar.com/> fpm translation-status

Never marked: FPM.ftd
Up to date: example01.md
Up to date: example02.ftd
Never marked: example03.ftd
Missing: example04.ftd
Missing: example05.ftd
Accept official translations

While anyone can start a package as a translation candidate to your master package, you get to decide what all packages act as official for your package.

The translation candidate repository(bar.com) can be marked an official translation of foo.com by mapping the the same in foo.com/FPM.ftd file along with providing the name of the language the current package belongs to.

The translation

foo.com/FPM.ftd
-- import: fpm

-- fpm.package: foo.com
language: English
translation: bar.com
Checking translation status of the master package
You can check the translation status of the various official translations of your package by using the fpm translation-status command. For a master package, it returns a global view across all the translations
master fpm translation-status
$/foo.com/> fpm translation-status

Status for `bar.com` package:
Never marked: 2
Missing: 2
Out-dated: 0
Up to date: 2
Making further changes in your master package
Making any changes in your master repo once the translation package has been synchronized will lead to that particular document in the translation package getting downgraded to Out-dated.
Make some changes
$/foo.com/> echo "\n-- ftd.text: Hello World" >> example01.ftd

\$/foo.com/> fpm sync

Repo for foo.com is github, directly syncing with .history.
example01.ftd
Once this package is deployed, the next time we run fpm translation-status in context of the translation package(/bar.com/), we should see the Out-dated document status
bar.com translation-status
$/bar.com/> fpm translation-status

Never marked: FPM.ftd
Out-dated: example01.md
Up to date: example02.ftd
Never marked: example03.ftd
Missing: example04.ftd
Missing: example05.ftd