Skip to content

Commit 538f78f

Browse files
committed
ov-components: Update README.md for openvidu-custom-lang tutorial with detailed instructions on custom language integration and configuration
1 parent 6604878 commit 538f78f

1 file changed

Lines changed: 118 additions & 1 deletion

File tree

  • openvidu-components-angular/openvidu-custom-lang
Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
# openvidu-custom-lang
1+
# openvidu-custom-lang
2+
3+
This tutorial demonstrates how to add a custom language to the OpenVidu Angular components library.
4+
5+
## Overview
6+
7+
The OpenVidu Angular components library supports internationalization (i18n) out of the box. This tutorial shows you how to:
8+
9+
1. Create a custom language file with translations
10+
2. Configure the OpenVidu components to use your custom language
11+
3. Allow users to switch between different languages
12+
13+
## Prerequisites
14+
15+
- Node.js and npm installed
16+
- Angular CLI installed
17+
- Basic knowledge of Angular and TypeScript
18+
19+
## Project Structure
20+
21+
```
22+
src/
23+
├── app/
24+
│ └── app.component.ts # Main component with OpenVidu configuration
25+
├── assets/
26+
│ └── lang/
27+
│ └── custom.json # Custom language translations (Spanish)
28+
└── styles.scss # Custom styling
29+
```
30+
31+
## How It Works
32+
33+
### 1. Custom Language File
34+
35+
The custom language translations are stored in `src/assets/lang/custom.json`.
36+
37+
> The default structure of the JSON file can be found in one of the built-in language files provided by OpenVidu Components Angular. Check it [here](https://github.com/OpenVidu/openvidu/tree/master/openvidu-components-angular/projects/openvidu-components-angular/src/lib/lang).
38+
39+
### 2. Component Configuration
40+
41+
In `src/app/app.component.ts`, the OpenVidu videoconference component is configured with:
42+
43+
```typescript
44+
<ov-videoconference
45+
[token]="token"
46+
[livekitUrl]="LIVEKIT_URL"
47+
[lang]="'es'" // Default language
48+
[langOptions]="[ // Available language options
49+
{ name: 'English', lang: 'en' },
50+
{ name: 'custom', lang: 'custom' }
51+
]"
52+
(onTokenRequested)="onTokenRequested($event)"
53+
></ov-videoconference>
54+
```
55+
56+
### 3. Language Options
57+
58+
- `'en'`: Built-in English translations
59+
- `'es'`: Built-in Spanish translations
60+
- `'custom'`: Your custom translations from the JSON file
61+
62+
## Running the Tutorial
63+
64+
1. **Install dependencies:**
65+
```bash
66+
npm install
67+
```
68+
69+
2. **Start the development server:**
70+
```bash
71+
npm start
72+
```
73+
74+
3. **Open your browser** and navigate to `http://localhost:5080`
75+
76+
4. **Join a room** and test the language switching functionality
77+
78+
## Customizing the Language
79+
80+
### Adding New Translations
81+
82+
1. Open `src/assets/lang/custom.json`
83+
2. Add new translation keys following the existing structure
84+
3. The keys should match the ones used by OpenVidu components
85+
86+
### Creating Multiple Custom Languages
87+
88+
1. Create additional JSON files in `src/assets/lang/` (e.g., `french.json`, `german.json`)
89+
2. Update the `langOptions` in `app.component.ts` to include your new languages
90+
3. Make sure the JSON files are included in the Angular build (check `angular.json`)
91+
92+
### Changing the Default Language
93+
94+
Modify the `[lang]` property in `app.component.ts`:
95+
96+
```typescript
97+
[lang]="'custom'" // Use custom language as default
98+
```
99+
100+
## Key Features Demonstrated
101+
102+
- **Custom Language Support**: How to provide your own translations
103+
- **Language Switching**: Allow users to change languages at runtime
104+
- **Asset Management**: How to include language files in Angular builds
105+
- **Component Configuration**: Proper setup of OpenVidu components with i18n
106+
107+
## Next Steps
108+
109+
- Explore the OpenVidu documentation for more i18n features
110+
- Add more languages to your application
111+
- Implement language persistence (save user preference)
112+
- Create dynamic language loading for better performance
113+
114+
## Learn More
115+
116+
- [OpenVidu Angular Components Documentation](https://docs.openvidu.io/en/stable/components/)
117+
- [Angular Internationalization](https://angular.io/guide/i18n)
118+
- [OpenVidu Tutorials](https://docs.openvidu.io/en/stable/tutorials/)

0 commit comments

Comments
 (0)