1 Localization
b24hugst edited this page 2026-05-15 09:52:12 +00:00

How to use

1. Create an entry in both json files en/sv

2. Import UseLanguage

3. Use translate("xxx.xxx")

Example:

import {useLanguage} from '../features/useLanguage';

export default function Legal() {
    const { translate } = useLanguage();

    return (
        <>
            <h1>{translate('legal.title')}</h1>
            <p>{translate('legal.content')}</p>
        </>
    );
}

Standard

Should be written using namespaces, with the page/component as the root namespace, and additional namespaces for subsections where suitable. Linebreaks should be used after every key for better readability and structure. Groups should be written in alphabetical order.

Don't forget that if two keys have the same starting letter, you need to sort using the second one, and so on. And that 0 - 9 comes before A - Z.

Here's an example (added extra spaces for readability):

{
	"settings.account.accountTitle": "Account",
	"settings.account.displayName": "Display Name",
	"settings.account.email": "E-mail",
	"settings.account.password": "Password",

	"settings.application.accessibility": "Accessibility",
	"settings.application.applicationTitle": "Application",
	"settings.application.defaultPage": "Default Page",

	"settings.preferences.language": "Language",
	"settings.preferences.notifications": "Notifications",
	"settings.preferences.preferencesTitle": "Preferences",

	"settings.privacySecurity.2FA": "Two-Factor Authentication",
	"settings.privacySecurity.deleteAccount": "Delete Account",
	"settings.privacySecurity.privacySecurityTitle": "Privacy & Security",
	
	"settings.settingsTitle": "Settings",
}