From a9c6daf71537647b6b089bd62266e7d2af4ad286 Mon Sep 17 00:00:00 2001 From: Ahmed Nefzaoui Date: Mon, 8 Nov 2021 15:20:55 -0800 Subject: [PATCH] Adding an Arabic example to the homepage of Project Fluent --- public/index.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++- src/controls.js | 2 +- src/example.js | 2 +- src/index.js | 44 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 92 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 84541d4..8d26329 100644 --- a/public/index.html +++ b/public/index.html @@ -305,6 +305,53 @@

The Polish Translation

+ +
+
+
+

The Arabic Translation

+ +

+ + The Arabic translation is yet another example of how flexible Fluent can be, using the example of + few and many. + +

+

+ + In this example we added a tabs-count-full variable + that stores all the possible plural (textual) variations of the word + tab. Arabic has + 6 variations for a numbered element. + 0, 1, 2, few (3~10, 103~110, 1003), many + (11~99, 311~399) and other (100~102, 200~202, + 300~302, …).
+ After we prodive a definition for each variation all we have to do + then is include it in our usual messages. This reduces the amount + of work needed to be done by the localization community, by + defining the 6 possible cases of a word in one place then calling + it in any phrase without worrying about its integration status. + +

+

+ + For this example to work we had to alter the min and + max parameters of the slider so it can put into + consideration the cases of many like + 11, 12, 18, …. + +

+ +

+ + Also adding dir="auto" reorganized the variables + to the correct order in our Arabic example since it's an RTL + language. + +

+
+
@@ -337,4 +384,4 @@

The Polish Translation

- + \ No newline at end of file diff --git a/src/controls.js b/src/controls.js index c61c478..4adea52 100644 --- a/src/controls.js +++ b/src/controls.js @@ -7,7 +7,7 @@ export function TextInput(props) { return (
${name}
-
+
{id}
-
{value}
+
{value}
); } diff --git a/src/index.js b/src/index.js index 9069218..18014dd 100644 --- a/src/index.js +++ b/src/index.js @@ -42,8 +42,8 @@ function Example0() { } ReactDOM.render( - , - document.getElementById('demo-app') + , + document.getElementById('demo-app') ); const example1 = { @@ -171,3 +171,43 @@ ReactDOM.render( , document.getElementById('example3-app') ); + + + +const example4 = { + locale: "ar", + translations: ftl` + tabs-close-button = أغلق + tabs-count-full = {$tabCount -> + [one] تبويب واحد + [two] تبويبان + [few] {$tabCount} تبوبات + [many] {$tabCount} تبويبا + *[other] {$tabCount} تبويب + } + tabs-close-tooltip = {tabs-close-button} {tabs-count-full} + tabs-close-warning = + أنت على وشك إغلاق {tabs-count-full}. + هل أنت متأكد من المواصالة؟ + + ## Syncing + + -sync-brand-name = حساب فيرفوكس + + sync-dialog-title = {-sync-brand-name} + sync-headline-title = {-sync-brand-name}: أفضل طريقة لتحمل بياناتك معك أينما كنت. + sync-signedout-title = + سجل الدخول بإستخدام {-sync-brand-name} الخاص بك. + `, + externals: { + tabCount: 2, + }, + height: "37rem", +}; + +ReactDOM.render( + + + , + document.getElementById('example4-app') +);