$t18s Module Reference
The $t18s
module contains all runtime code for t18s. It is how you interact with the library.
type Locale
A union type of all the locales you have registered with t18s.
type Locale = "en" | "de";
locales
An array of all the locales you have registered with t18s. Useful for places where you need to iterate over all locales, such as Locale Switchers or SEO.
$locale
Store
A writable store containing the currently active locale.
const locale = Writable<Locale>;
isLocale
A convenience function for checking if something is a valid locale or not. Only the locales that are registered with t18s are considered valid.
const isLocale = (thing: any) => thing is Locale;
It is useful for quickly creating a param matcher for locales.
src/params/locale.js
import { isLocale } from "$t18s";
export const match = isLocale;
setLocale
Sets the current locale. Useful for Locale Switchers.
const fallbackLocale
The fallback locale you specified in your config, or null if you don’t specify one. Will be definitely typed based on your config.
const fallbackLocale: Locale | null; //will be one or the other based on your config