Summary
Fluent will allow us to properly apply grammar rules, which we would otherwise need to code in C# every time. We might be able to handle the grammar in the English language, but other languages with more complex rules for word forms would have a hard time. We can also use Fluent to store status texts and perform fancy formatting.
Examples
en-US.ftl
coins =
{ $count ->
[one] { $count } coin
*[other] { $count } coins
}
C#
loc.Get("coins", ("count", 1));
loc.Get("coins", ("count", 5));
Output
en-US.ftl
player-joined =
{ $gender ->
[male] He joined the game.
[female] She joined the game.
*[other] They joined the game.
}
C# Usage
loc.Get("player-joined", ("gender", "female"));
Output
She joined the game.
en-US.ftl
quest-status =
{ $completed ->
[true] Quest Completed!
*[false] Quest In Progress...
}
C# Usage
loc.Get("quest-status", ("completed", true));
Output
Quest Completed!
en-US.ftl
start-button =
.label = Start Game
.tooltip = Begin a new adventure
C# Usage
var message = bundle.GetMessage("start-button");
var tooltip = bundle.FormatPattern(message.Attributes["tooltip"]);
Output
Begin a new adventure
en-US.ftl
score = Score: { NUMBER($points) }
C#
loc.Get("score", ("points", 12345));
Output
Score: 12,345
Links
https://firefox-source-docs.mozilla.org/l10n/fluent/index.html
https://docs.spacestation14.com/en/ss14-by-example/fluent-and-localization.html
Summary
Fluent will allow us to properly apply grammar rules, which we would otherwise need to code in C# every time. We might be able to handle the grammar in the English language, but other languages with more complex rules for word forms would have a hard time. We can also use Fluent to store status texts and perform fancy formatting.
Examples
en-US.ftl
C#
Output
en-US.ftl
C# Usage
loc.Get("player-joined", ("gender", "female"));Output
She joined the game.en-US.ftl
C# Usage
loc.Get("quest-status", ("completed", true));Output
Quest Completed!en-US.ftl
C# Usage
Output
Begin a new adventureen-US.ftl
score = Score: { NUMBER($points) }C#
loc.Get("score", ("points", 12345));Output
Score: 12,345Links
https://firefox-source-docs.mozilla.org/l10n/fluent/index.html
https://docs.spacestation14.com/en/ss14-by-example/fluent-and-localization.html