The Share MVP platform uses a centralized text management system to prepare for internationalization (i18n) and make text updates easier to manage. All user-facing text is centralized in src/lib/texts.ts.
The main text repository is located at src/lib/texts.ts and contains all user-facing text organized by categories:
export const texts = {
// Authentication-related text
auth: {
emailPlaceholder: 'E-Mail Adresse',
passwordPlaceholder: '••••••••••',
loginFailed: 'Login fehlgeschlagen.',
// ... more auth texts
},
// Navigation text
nav: {
login: 'Login',
register: 'Registrieren',
// ... more navigation texts
},
// Error messages
errors: {
changesNotSaved: 'Die Änderungen konnten nicht gespeichert werden!',
// ... more error messages
},
// Success messages
success: {
changesSaved: 'Die Änderungen wurden gespeichert!',
// ... more success messages
},
// Form labels and placeholders
forms: {
username: 'Nutzername',
// ... more form texts
},
// Buttons
buttons: {
save: 'Speichern',
// ... more button texts
},
// General UI text
ui: {
resultsFound: (count: number) => `${count} Dinge gefunden`,
// ... more UI texts
},
// Page-specific text
pages: {
about: {
title: 'Über AllerLeih',
// ... page-specific texts
},
// ... more pages
},
};
Import the texts and use them directly in your components:
<script lang="ts">
import { texts } from '$lib/texts';
</script>
<!-- Use in HTML -->
<span>{texts.forms.email}</span>
<input placeholder={texts.auth.emailPlaceholder} />
<button>{texts.buttons.save}</button>
<!-- For dynamic text with parameters -->
<p>{texts.ui.resultsFound(itemCount)}</p>
Import and use texts in your server-side code:
import { texts } from '$lib/texts';
// Use in error responses
return fail(400, {
fail: true,
message: texts.errors.loginFailed,
});
// Use in success responses
return {
success: true,
message: texts.success.changesSaved,
};
src/lib/texts.tsauth)nav)errors)success)forms)buttons)ui)pages)The current structure is designed to be easily extendable for full internationalization:
// Future i18n structure
export const texts = {
en: {
auth: {
/* English texts */
},
// ... other categories
},
de: {
auth: {
/* German texts */
},
// ... other categories
},
};
This would allow for language switching and localization without major structural changes.