diff --git a/build.rs b/build.rs index f85f7ce..2e0afde 100644 --- a/build.rs +++ b/build.rs @@ -17,6 +17,7 @@ fn update_po() { println!("Updating {}", lang.clone()); // Update it Command::new("msgmerge") + .arg("-U") .arg(po_path.to_str().unwrap()) .arg(pot_path.to_str().unwrap()) .spawn() diff --git a/po/en.po b/po/en.po index 01a565e..bbe17a7 100644 --- a/po/en.po +++ b/po/en.po @@ -14,3 +14,8 @@ msgstr "" msgid "Welcome on {{ instance_name }}" msgstr "Welcome on {{ instance_name }}" + +msgid "One follower" +msgid_plural "{{ count }} followers" +msgstr[0] "One follower" +msgstr[1] "{{ count }} followers" diff --git a/po/en.po~ b/po/en.po~ new file mode 100644 index 0000000..01a565e --- /dev/null +++ b/po/en.po~ @@ -0,0 +1,16 @@ +msgid "" +msgstr "" +"Project-Id-Version: plume\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-06-15 16:33-0700\n" +"PO-Revision-Date: 2018-06-15 16:33-0700\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Welcome on {{ instance_name }}" +msgstr "Welcome on {{ instance_name }}" diff --git a/po/fr.po b/po/fr.po index 2e3a767..ad0a929 100644 --- a/po/fr.po +++ b/po/fr.po @@ -14,3 +14,8 @@ msgstr "" msgid "Welcome on {{ instance_name }}" msgstr "Bienvenue sur {{ instance_name }}" + +msgid "One follower" +msgid_plural "{{ count }} followers" +msgstr[0] "{{ count }} abonné⋅e" +msgstr[1] "{{ count }} abonné⋅e⋅s" diff --git a/po/fr.po~ b/po/fr.po~ new file mode 100644 index 0000000..2e3a767 --- /dev/null +++ b/po/fr.po~ @@ -0,0 +1,16 @@ +msgid "" +msgstr "" +"Project-Id-Version: plume\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-06-15 16:33-0700\n" +"PO-Revision-Date: 2018-06-15 16:33-0700\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +msgid "Welcome on {{ instance_name }}" +msgstr "Bienvenue sur {{ instance_name }}" diff --git a/po/plume.pot b/po/plume.pot index 8d2f16a..e654621 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -14,3 +14,8 @@ msgstr "" msgid "Welcome on {{ instance_name }}" msgstr "" + +msgid "One follower" +msgid_plural "{{ count }} followers" +msgstr[0] "" +msgstr[1] "" diff --git a/src/i18n.rs b/src/i18n.rs index 96c699f..caad569 100644 --- a/src/i18n.rs +++ b/src/i18n.rs @@ -58,6 +58,16 @@ fn tera_gettext(msg: serde_json::Value, ctx: HashMap) Ok(serde_json::Value::String(Tera::one_off(trans.as_ref(), &ctx, false).unwrap_or(String::from("")))) } -pub fn tera(t: &mut Tera) { - t.register_filter("_", tera_gettext) +fn tera_ngettext(msg: serde_json::Value, ctx: HashMap) -> Result { + let trans = ngettext( + ctx.get("singular").unwrap().as_str().unwrap(), + msg.as_str().unwrap(), + ctx.get("count").unwrap().as_u64().unwrap() as u32 + ); + Ok(serde_json::Value::String(Tera::one_off(trans.as_ref(), &ctx, false).unwrap_or(String::from("")))) +} + +pub fn tera(t: &mut Tera) { + t.register_filter("_", tera_gettext); + t.register_filter("_n", tera_ngettext); } diff --git a/templates/users/details.html.tera b/templates/users/details.html.tera index a918474..524754d 100644 --- a/templates/users/details.html.tera +++ b/templates/users/details.html.tera @@ -42,7 +42,7 @@
- {{ n_followers }} follower{{ n_followers | pluralize }} + {{ "{{ count }} followers" | _n(singular="One follower", count=n_followers) }}
diff --git a/translations/en/LC_MESSAGES/plume.mo b/translations/en/LC_MESSAGES/plume.mo index a6d290e..cfc0f64 100644 Binary files a/translations/en/LC_MESSAGES/plume.mo and b/translations/en/LC_MESSAGES/plume.mo differ diff --git a/translations/fr/LC_MESSAGES/plume.mo b/translations/fr/LC_MESSAGES/plume.mo index bdee9a7..70ea716 100644 Binary files a/translations/fr/LC_MESSAGES/plume.mo and b/translations/fr/LC_MESSAGES/plume.mo differ