// Route: GET /i18n (locale negotiation, plurals, .po dump) #include "support/Assert.hpp" using namespace molo::example::test; using molo::example::fw::Method; int main() { Fixture f; auto en = f.client->get("/i18n?n=1"); check(en.status == 200, "status 200"); check(contains(en.headers.get("Content-Type"), "text/html"), "html"); check(contains(en.body, "1 item<"), "english singular"); check(en.headers.get("Content-Language") == "en", "content-language en"); auto ru = f.client->get("/i18n?lang=ru&n=22"); check(contains(ru.body, "22 предмета"), "russian few form"); auto ru5 = f.client->get("/i18n?lang=ru&n=5"); check(contains(ru5.body, "5 предметов"), "russian many form"); auto fr = f.client->get("/i18n?lang=fr&n=0"); check(contains(fr.body, "0 article<"), "french zero is singular"); auto hdr = f.client->request(Method::Get, "/i18n?n=2", "", {{"Accept-Language", "de;q=0.5, nl;q=0.9"}}); check(hdr.headers.get("Content-Language") == "nl", "accept-language q weights"); auto prm = f.client->request(Method::Get, "/i18n?lang=ja", "", {{"Accept-Language", "nl"}}); check(prm.headers.get("Content-Language") == "ja", "?lang beats header"); auto bad = f.client->get("/i18n?n=abc"); check(bad.status == 422 && contains(bad.body, "field-error"), "inline validation error"); check(!contains(bad.body, "{\""), "no raw json in page"); auto huge = f.client->get("/i18n?n=99999999"); check(huge.status == 422, "limit: count capped"); auto po = f.client->get("/i18n/po?lang=ru"); check(contains(po.body, "msgstr[2]") && contains(po.body, "nplurals=3"), "po catalog"); check(f.client->get("/i18n/po?lang=xx").status == 404, "unknown locale 404"); check(f.client->request(Method::Post, "/i18n").status == 405, "post is 405"); return finish("i18n/page"); }