Draft the French version of your app and emails, then have a person finish it.
A script that reads your English en.json, asks a model hosted in Montréal for Quebec French drafts of the strings that have none, rejects any draft that breaks a {placeholder}, %s or plural, flags words your glossary rules out, and writes a review file. Nothing reaches fr-CA.json unchecked, and CI fails until a person has read the drafts.
Facts checked
Drafts, not translations
If you sell software in Quebec, the Charter of the French language asks for a French version on terms at least as favourable as any other language. Bill 96 and French in apps covers what the Charter requires, section by section. This guide takes no position on whether machine translation meets it. It treats the model’s output as a first draft that a French speaker reviews, which is how it should be treated anyway: on our test strings the model made mistakes that no automated check caught.
The workflow has four parts: a glossary that goes into the prompt and is checked afterwards, a placeholder check in code, a drafting script that only touches strings with no French yet, and a review step that CI enforces.
Set up an endpoint
Create an AI endpoint with gemma-4-26b-a4b, the model with the best answers of the chat models Canner serves, and attach it to the project, or create a key for your CI. Attaching sets OPENAI_BASE_URL and OPENAI_API_KEY on the next deploy, so the official openai package needs no configuration.
canner ai create translations --models gemma-4-26b-a4b
canner ai attach translations # in the project folder; or create a key for CI
npm install openai
# locally or in CI, with the endpoint's key
export OPENAI_BASE_URL=https://ai.canner.ca/v1
export OPENAI_API_KEY=...
node translate-fr.mjs locales/en.json locales/fr-CA.jsonA glossary, in the prompt and in the check
Quebec has settled terms for most interface words, and a model trained mostly on France French will not always pick them. The Office québécois de la langue française (OQLF) publishes its recommendations in the Vitrine linguistique. These are the ones that matter most in app strings:
- Each entry does two jobs.
termsForadds the entries that apply to a batch to the prompt.checkGlossarychecks the draft afterwards and turns a miss into a note for the reviewer. It never rejects a draft: “Déconnexion” for “Sign out” is fine as a menu label even though the glossary says “se déconnecter”. - Remove placeholders before checking words. Our first version flagged
{plan}as the forbidden English word “plan”. - Add `unless` for strings that use both words. “Uploads and downloads” legitimately contains téléchargements.
- The other entries (déconnexion, forfait, tableau de bord, paramètres) are the terms Canner’s own dashboard uses. Replace them with your product’s vocabulary.
// i18n/glossary.mjs: your terms, checked against OQLF's Vitrine linguistique.
// `when` matches the English; the French must match `want` and must not match
// `avoid` (unless the English also matches `unless`).
export const GLOSSARY = [
{ en: "upload", fr: "téléverser, téléversement", when: /upload/i, want: /téléver/i, avoid: /télécharg\w*|upload\w*/i, unless: /download/i },
{ en: "download", fr: "télécharger, téléchargement", when: /download/i, want: /télécharg/i },
{ en: "email", fr: "courriel, adresse courriel", when: /e-?mail/i, want: /courriel/i, avoid: /\be-?mail\b/i },
{ en: "cookie", fr: "témoin", when: /cookie/i, want: /témoin/i, avoid: /cookie/i },
{ en: "sign out, log out", fr: "se déconnecter, déconnexion", when: /(sign|log) ?out/i, want: /déconne/i },
{ en: "sign in, log in", fr: "se connecter, connexion", when: /(sign|log) ?in\b/i, want: /conne/i },
{ en: "plan (subscription)", fr: "forfait", when: /\bplan\b/i, want: /forfait/i, avoid: /\bplan\b/i },
{ en: "dashboard", fr: "tableau de bord", when: /dashboard/i, want: /tableau de bord/i },
{ en: "settings", fr: "paramètres", when: /settings/i, want: /paramètres/i },
{ en: "unsubscribe", fr: "se désabonner", when: /unsubscribe/i, want: /désabonn/i },
];
// The entries that apply to some strings, as lines for the prompt.
export const termsFor = (texts) =>
GLOSSARY.filter((g) => texts.some((t) => g.when.test(t))).map((g) => `- ${g.en} → ${g.fr}`);
// Problems to show the reviewer. Placeholders are removed first: {plan} is not the word "plan".
export function checkGlossary(en, fr) {
const bare = (s) => s.replace(/\{\w+\}|%(\d+\$)?\w/g, "");
[en, fr] = [bare(en), bare(fr)];
return GLOSSARY.filter((g) => g.when.test(en)).flatMap((g) => [
...(g.want.test(fr) ? [] : [`expected “${g.fr}” for “${g.en}”`]),
...(g.avoid?.test(fr) && !g.unless?.test(en) ? [`“${fr.match(g.avoid)[0]}” is not the term for “${g.en}”`] : []),
]);
}| English | Quebec French | Not | OQLF note |
|---|---|---|---|
| upload † | téléverser, téléversement | uploader, télécharger | Téléverser sends data from the local device to a remote system; télécharger is the opposite direction |
| download † | télécharger, téléchargement | — | Kept distinct from téléverser |
| email † | courriel | email, mail | Courrier électronique and message électronique are also recommended |
| cookie † | témoin, témoin de connexion | cookie | Recommended by the OQLF in December 2023 |
| ? ! ; † | no space before, or a thin space | a full space before | The OQLF prefers no space; a thin space is acceptable where available |
† Competitor details come from each vendor’s own published pages on the dates shown; prices and plans change, so check the vendor before you decide. upload (2026-11-23) · download (2026-11-23) · email (2026-11-23) · cookie (2026-11-23) · ? ! ; (2026-11-23)
Placeholders: check them in code, not in the prompt
A translated string that renames {name} to {nom}, translates plural to pluriel, or drops %s breaks at runtime, often in an email nobody tests in French. Asking the model to keep placeholders helps; checking the result is what makes it safe. This check parses ICU messages ({name}, {count, plural, …}, select) and printf tokens, and compares the French with the English: same argument names and types, same branches, every plural branch that had # still has it, same printf tokens.
French has one plural rule English does not: one covers 0 and 1. So a French one branch written as “un fichier” would print “un fichier” for zero files. The check rejects a plural branch that lost its #. It accepts an added many branch, which French plural rules allow.
// i18n/placeholders.mjs: does the French keep every placeholder of the English?
// Compares ICU arguments ({name}, {count, plural, ...}), plural/select branches,
// '#' in plural branches, and printf tokens (%s, %1$s, %d).
function close(s, open) {
let depth = 0;
for (let i = open; i < s.length; i++) {
if (s[i] === "{") depth++;
else if (s[i] === "}" && --depth === 0) return i;
}
throw new Error("unbalanced {");
}
// "count, plural, one {...} other {...}" -> ["count", "plural", "one {...} other {...}"]
function head(body) {
const parts = [];
let depth = 0, cur = "";
for (const ch of body) {
if (ch === "{") depth++;
if (ch === "}") depth--;
if (ch === "," && depth === 0 && parts.length < 2) { parts.push(cur.trim()); cur = ""; continue; }
cur += ch;
}
return [...parts, cur.trim()];
}
function icu(s, out = { args: [], noHash: 0 }) {
for (let i = 0; i < s.length; i++) {
if (s[i] === "}") throw new Error("unbalanced }");
if (s[i] !== "{") continue;
const end = close(s, i);
const [name, type, branches] = head(s.slice(i + 1, end));
if (type === "plural" || type === "select" || type === "selectordinal") {
const keys = [];
for (let j = 0; j < branches.length; ) {
const k = branches.slice(j).match(/^\s*(=?\w+)\s*\{/);
if (!k) { if (branches.slice(j).trim()) throw new Error(`bad branch in {${name}}`); break; }
const open = j + k[0].length - 1, shut = close(branches, open);
const text = branches.slice(open + 1, shut);
// French "many" is optional; English has no such branch
if (k[1] !== "many") {
keys.push(k[1]);
if (type !== "select" && !text.includes("#")) out.noHash++;
}
icu(text, out);
j = shut + 1;
}
out.args.push(`${name}:${type}:${keys.sort().join("|")}`);
} else {
out.args.push(type ? `${name}:${type}` : name);
}
i = end;
}
return out;
}
const signature = (s) => {
const { args, noHash } = icu(s);
const printf = s.match(/%(\d+\$)?[-+0#]*\d*(\.\d+)?[sdif@]/g) ?? [];
return { args: args.sort().join(" "), noHash, printf: printf.sort().join(" ") };
};
// Returns a list of problems; empty means the placeholders survived.
export function checkPlaceholders(en, fr) {
let a, b;
try { a = signature(en); } catch (e) { return [`English: ${e.message}`]; }
try { b = signature(fr); } catch (e) { return [e.message]; }
const problems = [];
if (a.args !== b.args) problems.push(`arguments ${b.args || "(none)"} ≠ ${a.args || "(none)"}`);
if (b.noHash > a.noHash) problems.push("a plural branch lost its #");
if (a.printf !== b.printf) problems.push(`printf ${b.printf || "(none)"} ≠ ${a.printf || "(none)"}`);
return problems;
}The drafting script
The script drafts only keys that are missing from fr-CA.json, so a string a person has corrected is never drafted again. It sends ten strings per request with a JSON schema in response_format; the endpoint guarantees the answer matches the schema, so every key comes back and parsing never fails. Drafts that break a placeholder get one retry with the reason in the prompt. Drafts that still break one stay out of fr-CA.json.
- When you change an English string, delete its French key. The script only looks for missing keys; it can’t tell that the English moved under an existing translation.
- Format dates and numbers with the locale, not the string.
%sfilled with “November 30” is still English. UseIntl.DateTimeFormat("fr-CA")for what goes into the placeholder. - The model runs on processors. In our runs, a batch of ten strings took tens of seconds. That suits a script you run when strings change, or a CI job; it does not suit translating on each request. Run large backlogs as a background job.
// translate-fr.mjs: draft fr-CA strings for keys that have no French yet.
// node translate-fr.mjs locales/en.json locales/fr-CA.json
import fs from "node:fs";
import OpenAI from "openai";
import { checkPlaceholders } from "./i18n/placeholders.mjs";
import { termsFor, checkGlossary } from "./i18n/glossary.mjs";
const [src, dest] = process.argv.slice(2);
const review = dest.replace(/\.json$/, ".review.md");
const ai = new OpenAI(); // OPENAI_BASE_URL and OPENAI_API_KEY from the environment
const MODEL = "gemma-4-26b-a4b";
if (fs.existsSync(review)) throw new Error(`Review ${review} and delete it first.`);
const flat = (o, p = "") => Object.entries(o).flatMap(([k, v]) =>
typeof v === "object" && v !== null ? flat(v, `${p}${k}.`) : [[`${p}${k}`, v]]);
function nest(pairs) {
const o = {};
for (const [k, v] of pairs) {
const path = k.split(".");
let cur = o;
for (const p of path.slice(0, -1)) cur = cur[p] ??= {};
cur[path.at(-1)] = v;
}
return o;
}
const prompt = (batch, feedback) => [
"Translate these user-interface strings from English to Quebec French (fr-CA) for a web app.",
"- Keep every placeholder exactly as written: {name}, %s, and in {count, plural, one {...} other {...}}",
" keep the argument name, the word plural and the branch names; translate only the text inside the branches, and keep #.",
"- Use vous. Keep the length close to the English. Quebec typography: no space before ? or !.",
...termsFor(batch.map(([, s]) => s)).length
? ["- Use these terms:", ...termsFor(batch.map(([, s]) => s))] : [],
...feedback ? [`- Your previous draft broke placeholders: ${feedback}. Fix them.`] : [],
"Return a JSON object with the same keys.",
JSON.stringify(Object.fromEntries(batch), null, 2),
].join("\n");
async function draft(batch, feedback) {
const schema = {
type: "object",
properties: Object.fromEntries(batch.map(([k]) => [k, { type: "string" }])),
required: batch.map(([k]) => k),
additionalProperties: false,
};
for (;;) {
try {
const r = await ai.chat.completions.create({
model: MODEL,
temperature: 0.2,
messages: [{ role: "user", content: prompt(batch, feedback) }],
response_format: { type: "json_schema", json_schema: { name: "strings", schema, strict: true } },
});
return JSON.parse(r.choices[0].message.content);
} catch (e) {
if (e.status !== 429 && e.status !== 503) throw e; // server_busy or a model restarting
await new Promise((ok) => setTimeout(ok, Number(e.headers?.["retry-after"] ?? 30) * 1000));
}
}
}
const en = flat(JSON.parse(fs.readFileSync(src, "utf8")));
const fr = fs.existsSync(dest) ? flat(JSON.parse(fs.readFileSync(dest, "utf8"))) : [];
const done = new Set(fr.map(([k]) => k));
const todo = en.filter(([k]) => !done.has(k)); // reviewed French is never redrafted
const results = [];
for (let i = 0; i < todo.length; i += 10) { // 10 strings per request
const batch = todo.slice(i, i + 10);
const out = await draft(batch);
const broken = batch.filter(([k, s]) => checkPlaceholders(s, out[k]).length);
if (broken.length) { // one retry, for the broken ones only
const why = broken.map(([k, s]) => `${k}: ${checkPlaceholders(s, out[k]).join("; ")}`).join(" | ");
Object.assign(out, await draft(broken, why));
}
for (const [k, s] of batch) {
results.push({ k, en: s, fr: out[k], placeholders: checkPlaceholders(s, out[k]), glossary: checkGlossary(s, out[k]) });
}
}
// Drafts that keep their placeholders go into fr-CA.json; the others stay out,
// so the missing-string check keeps failing until a person writes them.
const ok = results.filter((r) => !r.placeholders.length);
fs.writeFileSync(dest, JSON.stringify(nest([...fr, ...ok.map((r) => [r.k, r.fr])]), null, 2) + "\n");
const md = [`# French drafts to review (${MODEL})`, "", `Fix the French in ${dest}, then delete this file.`, ""];
for (const r of results) {
const flag = r.placeholders.length ? "REJECTED" : r.glossary.length ? "CHECK" : "draft";
md.push(`## ${flag} ${r.k}`, "", `- en: ${r.en}`, `- fr: ${r.fr}`,
...r.placeholders.map((p) => `- placeholder: ${p}`), ...r.glossary.map((g) => `- term: ${g}`), "");
}
fs.writeFileSync(review, md.join("\n"));
console.log(`${results.length} drafted, ${results.length - ok.length} rejected, see ${review}`);The review step, enforced by CI
The script writes fr-CA.review.md next to the JSON: every new draft with a flag. REJECTED drafts are not in the JSON. CHECK drafts are in the JSON with a glossary note. Plain draft entries passed both checks and still need a person to read them. The reviewer fixes the French in fr-CA.json and deletes the review file. Here is an excerpt from our runs:
## CHECK files.uploadFailed
- en: Upload failed: {reason}
- fr: Échec de l'upload : {reason}
- term: expected “téléverser, téléversement” for “upload”
- term: “upload” is not the term for “upload”
## REJECTED files.empty
- en: {count, plural, =0 {No uploads yet} one {# upload} other {# uploads}}
- fr: {count, plural, =0 {Aucun téléversement} one {un téléversement} other {plusieurs téléversements}}
- placeholder: a plural branch lost its #
## draft files.shared
- en: {actor} shared {count, plural, one {a file} other {# files}} with you
- fr: {actor} a partagé {count, plural, one {un fichier} other {# de fichiers}} avec vousThe CI check
Run this on every pull request. It fails on missing French, on placeholders broken by the model or by a hand edit, and while a review file is still present. That last rule is what stops unread drafts from shipping. It extends the missing-string check in Bill 96 and French in apps.
// check-fr.mjs: run in CI. Fails on missing French, broken placeholders,
// and drafts nobody has reviewed yet.
// node check-fr.mjs locales/en.json locales/fr-CA.json
import fs from "node:fs";
import { checkPlaceholders } from "./i18n/placeholders.mjs";
const [enFile, frFile] = process.argv.slice(2);
const flat = (o, p = "") => Object.entries(o).flatMap(([k, v]) =>
typeof v === "object" && v !== null ? flat(v, `${p}${k}.`) : [[`${p}${k}`, v]]);
const en = flat(JSON.parse(fs.readFileSync(enFile, "utf8")));
const fr = Object.fromEntries(flat(JSON.parse(fs.readFileSync(frFile, "utf8"))));
const errors = en.flatMap(([k, s]) =>
(k in fr ? checkPlaceholders(s, fr[k]) : ["no French version"]).map((p) => `${k}: ${p}`));
if (fs.existsSync(frFile.replace(/\.json$/, ".review.md"))) errors.push("French drafts are waiting for review");
for (const e of errors) console.error(e);
process.exit(errors.length ? 1 : 0);What we saw on 27 real strings
We ran the script on 27 strings from a typical SaaS app on 2026-11-23: navigation, file uploads, a verification email, a cookie banner, billing and errors, with {name}, %s, %1$s and ICU plurals including an =0 branch. Gemma ran with and without the glossary. For comparison we also ran the smaller granite-4.2-3b on the eight hardest strings.
Gemma kept every placeholder in every run and chose téléverser, courriel and témoin on its own, even without the glossary. Granite did not, and the checks caught it. Neither check catches grammar, which is why the review step exists.
- Use Gemma for this. Granite is faster but ignored part of the glossary even when it was in the prompt.
- Our glossary check had false positives at first:
{plan}read as the word “plan”, and “Uploads and downloads” flagged for containing téléchargements. Both are fixed in the code above. Run the check on your existing French before you trust it.
| English | Draft | Model | Caught by |
|---|---|---|---|
| Upload failed: {reason} | Échec de l’upload : {reason} | Granite, no glossary | Glossary check |
| {count, plural, =0 {No uploads yet} one {# upload} …} | … one {# téléchargement} … | Granite, no glossary | Glossary check (the classic upload/download mix-up) |
| Same string | … one {un téléversement} other {plusieurs téléversements} | Granite, with glossary | Placeholder check: rejected, retried, still rejected, kept out of the JSON |
| Cookie settings | Paramètres des cookies | Granite, with glossary | Glossary check |
| Uploading {current} of {total}… | Envoi de {current} de {total}… | Granite, with glossary | Glossary check |
| {actor} shared {count, plural, one {a file} other {# files}} | … other {# de fichiers} | Granite | Nothing: the # is there. Reviewer |
| Uploaded {count, plural, one {# file} other {# files}} | {count, plural, one {# fichier} other {# fichiers}} téléversés | Gemma | Nothing: “1 fichier téléversés”. Reviewer |
| Didn’t get the email? Resend it | Courriel non reçu ? Le renvoyer | Gemma, first prompt | Nothing: space before “?”. We added the OQLF spacing rule to the prompt and it stopped |
| {fileName} is larger than {maxSize} MB. | {fileName} est plus gros que {maxSize} Mo. | Gemma | Nothing: correct but clumsy; “dépasse” reads better. Reviewer |
Running it on Canner
Your English strings, and any customer names that end up in test fixtures, are processed in memory on Canner’s server in Montréal and not stored; nothing is sent to another company or used for training (AI endpoints). Usage is measured in model time against a monthly allowance per plan; see AI endpoints for current allowances.
- Keep usage down: the script only drafts missing keys, sends ten strings per request, and retries only the broken ones. Set a requests-per-minute limit on the endpoint so a loop in CI can’t use the month’s allowance.
- When it’s busy: the service answers one request at a time. The script waits for
Retry-Afteron429 server_busyand on503. - Content policy: chat requests are checked by a safety model. Ordinary interface strings pass; a blocked string comes back as
400 content_filterand the script stops, so translate that one by hand.
Questions
Can AI translate my app to French for Bill 96?
It can draft the French. The Charter asks for a French version on terms at least as favourable as the English; a draft with grammar mistakes or English words left in does not get you there. Treat the output as a draft that a French speaker reviews, and enforce that review in CI.
Why does the model write télécharger for upload?
Télécharger means download in Quebec French; the OQLF term for upload is téléverser. Smaller models confuse the two. Put the term in a glossary in the prompt and check the draft for télécharg… when the English says upload and not download.
How do I stop machine translation from breaking {placeholders} and plurals?
Check them in code. Parse the ICU message and printf tokens in the English and the French, compare argument names, plural branches and # markers, and reject the draft if they differ. Prompting alone is not enough.
Which French plural branches do I need in ICU messages?
one and other. In French, one covers 0 and 1, so keep # in the one branch rather than writing “un”. A many branch is allowed but optional.
Do my strings leave Canada?
Not with Canner’s AI endpoints: the model runs on Canner’s server in Montréal, prompts and answers are processed in memory and not stored, and nothing is sent to another company.
Related
- GuideChatGPT, Copilot and GitHub Copilot: what they keep
- GuideGenerative AI in Quebec and Law 25
- GuideCanadian AI companies: who builds, who hosts, where prompts go
- GuidePrivate GPT: hosted API, self-hosted or on-premises
- GuideOllama, vLLM or llama.cpp: your own LLM API
- Guidebge-m3 embeddings: dimensions, limits, English and French
French drafts from a model in Montréal.
Create an AI endpoint, attach it to your project and run the script on your next set of strings. See AI endpoints.