Ulabase sends emails to the users of your app: the verification of a new account, the password reset, the invitation to a team, and the confirmation of a Stripe order.
You do not have to write them. The service has ready-made templates, with your app's name, color and logo from the Branding page.
The templates are now written in eight languages:
| Code | Language |
|---|---|
en |
English |
it |
Italian |
es |
Spanish |
fr |
French |
de |
German |
nl |
Dutch |
pt |
Portuguese |
pl |
Polish |
Your own templates can speak any other language too: Chinese, Japanese, Arabic, whatever your users read. The last section shows how.
Each user gets the email in their language. This post shows how to choose it.
How the service chooses the language
The service looks in three places, in this order, and takes the first it finds:
- The user's language. The
localefield of the user. - The language of the request. The
localeyour app sends with the call that sends the email. - The default of your service. The language you choose on the Branding page.
When none of them names a language, the email is in English.
An app in one language
Open Branding in the console, choose Language of the emails and click Save. That is all.
From then on, every email is in that language. The only exception is a user who chose another language for themselves.
An app in more languages
Your app knows which language the user is reading. Pass it as locale to the Kit calls that send an email:
import { register, invite, resendInvite, forgotPassword } from '@ulabase/kit';
const locale = 'it'; // the language of the page
await register(config, { email, password, firstName, lastName, teamName, locale });
await invite(config, 'luca@example.com', 'member', locale);
await resendInvite(config, 'luca@example.com', locale);
await forgotPassword(config, 'anna@example.com', locale);
register and invite also store the language on the new user, so the later emails are in it too.
Without the Kit, add "locale": "it" to the JSON body of POST /auth/register, /auth/invite, /auth/resend-invite and /auth/forgot-password.
Let the user choose
A language picker in your app saves the user's choice with one call:
import { updateProfile } from '@ulabase/kit';
await updateProfile(config, { locale: 'de' });
The user's choice comes first, whatever the app sends later.
Stripe
Checkout and the Customer Portal open in the language you pass, and the order emails are written in it:
const { url } = await createCheckoutSession(config, 'gold', 'month', 'it');
Any language, with your own templates
Our templates cover eight languages. For any other, write your own template and put every language in the same file, each in a <span lang="…">:
<span lang="en">Hi {{first-name}}, please verify your address.</span>
<span lang="it">Ciao {{first-name}}, verifica il tuo indirizzo.</span>
<span lang="zh">{{first-name}},您好,请验证您的邮箱地址。</span>
<span lang="ja">{{first-name}}さん、メールアドレスを確認してください。</span>
The service keeps the span in the user's language and drops the others. The code is any language code of 2 to 5 letters, so zh and ja work as well as it. A user whose language has no span gets the en one.
The subject is the <title> of the template, and works the same way. Your templates go on the Sign-up page, and they are sent from your own mail server, set on the Email page.
Learn more
The i18n page of the manual has the details, including what to do when an email arrives in the wrong language.
Build your app on Ulabase
Your backend is ready in minutes, and you spend your time on your app. The Free plan needs no credit card.