Fluent is a family of specifications, implementations, and localization practices developed by Mozilla. Now it is used in the Firefox browser. Using Fluent, translators can write more natural translations in their own language. Today, we present the Fluent version 1.0 file format specification. We invite developers of translation tools to try it out and share your impressions.
The Firefox browser supports about a hundred languages, and this challenges the developers in terms of localization. Many problems are difficult to solve using traditional approaches. The localization of software is dominated by the one-to-one translation markup with source text. The grammar of the source language (in the case of Mozilla - English) imposes serious restrictions on the availability of expressive means when translating.
Consider the following message that appears when a user tries to close a multi-tabbed Firefox window.
tabs-close-warning-multiple = You are about to close {$count} tabs. Are you sure you want to continue?
The message is displayed only if the tabs are 2 or more. In English, the word tab will always be in the plural - tabs. English-language developer will arrange such a message. It sounds correct for any $ count values.
In English, for all values of $ count, a single message variant is enough.
Many translators will notice that the word tab can take different forms depending on the value of $ count.
In the traditional approach to localization, the responsibility for correct processing of the message will lie on the translators. They should take into account that there may be several plural forms of words in other languages, even if there is only one in English. The more languages an application supports, the more serious the problem will become.
There are many grammatical and stylistic variations that cannot be directly compared between two languages. Supporting all these nuances with the traditional approach can be cumbersome. In some languages it is necessary to make compromises, in others there will be no suitable solution at all.
Fluent changes the distribution of roles in localization. Instead of requiring developers to consider all the possible nuances of all languages, Fluent tries to keep the texts in the source language in the simplest possible form.
We make it possible to transfer grammar and style of other languages regardless of the source text. Everything happens in isolation. The fact that one language can use more advanced localization logic does not affect other translation languages. Each localization in the program itself decides how difficult the translation text should be.
For example, we will look at the translation of the message on closing tabs into Czech. The word panel (tab) should take one of two forms: panely for the number of tabs 2, 3 and 4, and panel for all other values.
tabs-close-warning-multiple = {$count -> [few] Chystáte se zavřít {$count} panely. Opravdu chcete pokračovat? *[other] Chystáte se zavřít {$count} panelů. Opravdu chcete pokračovat? }
Fluent allows translators to write grammatically correct sentences and to freely use the expressive means of their language. Thanks to Fluent, the Czech translation uses correct plural forms for any possible values of $ count.
At the same time, no changes are required in the source text or code. The logic in the Czech localization does not affect all other localizations of the program. In French, this sentence will be as simple as English:
tabs-close-warning-multiple = Vous êtes sur le point de fermer {$count} onglets. Voulez-vous vraiment continuer ?
The concept of asymmetric localization has been Fluent's key innovation, which has been made possible by Mozilla’s multilingual software development experience for over 20 years. Many key ideas for Fluent were borrowed from the MessageFormat from ICU (International Component for Unicode) and from the XLIFF format.
At first glance, Fluent is like other localization solutions that allow you to use word variants for multiple nouns and words with a grammatical gender. Fluent, by contrast, uses a holistic approach to localization. Fluent develops these ideas by defining the syntax for the entire text file where translations are stored, and allowing references from one message to another.
A Fluent file can contain many messages, each of which is translated into the language of the translator. Messages may refer to other messages within the same file, or to messages from other files. At runtime, Fluent bundles files, and links are resolved inside this bundle.
Link to messages is a powerful tool to support the uniformity of translations. Once a certain translation can be reused in other translations. Fluent supports a special message type called term, which is well suited for reuse. The term identifier always starts with a dash.
-sync-brand-name = Firefox
After definition, the term -sync-brand-name can be used as a variable from other messages, always returning the correct text. The terms help to introduce uniformity according to the style guide. For example, they can be modified for special branding of informal assemblies or beta releases.
sync-dialog-title = {-sync-brand-name} sync-headline-title = {-sync-brand-name}: The best way to bring your data always with you sync-signedout-account-title = {-sync-brand-name}
Using the term directly in the middle of a sentence can cause problems in inflectional languages, or in languages with other text capitalization rules. The meaning of a term can be defined in several aspects, depending on the context. Consider the following definition of the term -sync-brand-name in Italian.
-sync-brand-name = {$capitalization -> *[uppercase] Account Firefox [lowercase] account Firefox }
Due to the asymmetric nature of Fluent, an Italian translator can define two forms for writing a brand. The case of upper case (default) is suitable for self-use or for use at the beginning of a sentence. A lower case variant may be requested by passing a capitalization parameter when the term is used within a large sentence.
sync-dialog-title = {-sync-brand-name} sync-headline-title = {-sync-brand-name}: il modo migliore per avere i tuoi dati sempre con te # . sync-signedout-account-title = Connetti il tuo {-sync-brand-name(capitalization: "lowercase")}
The definition of several variants of the term is a convenient technique that allows you to match the grammatical rules of many languages. In the following example, a Polish translator can use declensions to build the correct sentence in the sync-signedout-account-title message.
-sync-brand-name = {$case -> *[nominative] Konto Firefox [genitive] Konta Firefox [accusative] Kontem Firefox } sync-signedout-account-title = Zaloguj do {-sync-brand-name(case: "genitive")}
Fluent allows you to embed complex logic of language constructs where necessary. At the same time, just the translation remains simple. Fluent does not add complex implementation to simple constructs.
sync-signedout-caption = Take Your Web With You sync-signedout-caption = Il tuo Web, sempre con te sync-signedout-caption = Zabierz swoją sieć ze sobą sync-signedout-caption = So haben Sie das Web überall dabei.
Today we announce the first stable release of Fluent Syntax. This is a specification of the file format for storing translations, as well as a beta release of parsers for JavaScript, Python and Rust.
In the examples above, you saw what the Fluent syntax is. It is designed to be understandable for people with a small technical knowledge, and allows you to check and edit text with a minimum number of errors. Error recovery is an important point: one incorrect translation will not break the entire file or adjacent translations. Comments are useful for conveying the context of a specific message or an entire group. Translations can take several lines, which facilitates the work and markup of large fragments of text.
Fluent files can be opened in any text editor, which reduces the entry threshold for developers and localizers. The format is already supported by an open platform for translating Pontoon software from Mozilla.
Details on the syntax can be found in the Fluent Syntax Guide (eng). Formal definition can be found in the Fluent Syntax specification (eng). And if you just want to try Fluent, use the Fluent Playground , an online editor with snippets to share.
Firefox is a major factor in the development of Fluent. Firefox already uses more than 3000 Fluent messages . The migration to Fluent began last year, and is now in full swing. The Fluent format has proven to be a stable and flexible solution for complex interfaces, like the Firefox settings page. It is also used on many Mozilla web pages, such as Firefox Send and Common Voice .
We believe that Fluent is an excellent choice for applications in which simplicity and speed of execution are important, but at the same time requiring display of interface elements depending on a variety of variables. In particular, Fluent helps to create natural sentences in different languages in a limited space of mobile interfaces; in information rich social media platforms; and in games to transfer game statistics and explain mechanics to the player.
We'd love to hear about Fluent from developers or vendors. Fluent is being developed as a standard for the future, so we invite everyone to try it out and tell you what other problems you encounter in your work. With your help, we can improve Fluent to work on a variety of platforms and situations.
We are open to constructive criticism. Learn more about Fluent on the project website . If you have a story to tell, contact us at Fluent Discourse .
Source: https://habr.com/ru/post/448944/
All Articles