mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-02-28 19:35:57 +00:00
40 lines
718 B
Markdown
40 lines
718 B
Markdown
# WebAppLocalizer
|
|
|
|
Quick reference for AI-assisted development of the WebAppLocalizer class.
|
|
|
|
## Import
|
|
```html
|
|
<script src="/lollms_assets/js/web.app.localizer"></script>
|
|
```
|
|
|
|
## Initialization
|
|
```javascript
|
|
const localizer = new WebAppLocalizer(translations, localStoragePrefix, languageSelector);
|
|
```
|
|
|
|
## Key Methods
|
|
- `setLanguage(lang)`
|
|
- `getCurrentLanguage()`
|
|
- `getAvailableLanguages()`
|
|
- `translate(key)`
|
|
- `apply()`
|
|
|
|
## Translations Object Structure
|
|
```javascript
|
|
{
|
|
[langCode]: {
|
|
name: "Language Name",
|
|
translations: {
|
|
[key]: "Translation"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## HTML Usage
|
|
```html
|
|
<element data-translate="key"></element>
|
|
```
|
|
|
|
Apply translations: `localizer.apply();`
|