Getting Started
Estimated reading time: 3 minutes
This guide will walk you through the process of setting up and using typed-locale in your project. We'll cover installation, basic configuration, and a simple usage example.
Installation
First, you need to install typed-locale in your project. You can do this using npm, yarn, or pnpm.
Using npm:
Using yarn:
Using pnpm:
Basic Setup
Once you've installed typed-locale, you can start using it in your project. Here's a step-by-step guide to set up a basic translation system:
1. Create a Translation Object
First, create a file to define your translations. For example, translations.ts
:
2. Create a Translator
Next, create a translator using your translation object:
3. Use the Translator
Now you can use the translator in your application:
Type Safety
One of the key features of typed-locale is its type safety. TypeScript will catch errors if you try to use non-existent keys or provide incorrect variables:
Next Steps
This basic setup demonstrates the core functionality of typed-locale. In the following sections, we'll explore more advanced features such as:
- Working with multiple languages
- Using dictionaries for language switching
- Implementing lazy loading for large translation sets
- Advanced pluralization and variable usage
By mastering these concepts, you'll be able to create robust, type-safe internationalization systems for your TypeScript projects.