Skip to content

Commit

Permalink
[update] localization updated, locale, setlocale added
Browse files Browse the repository at this point in the history
  • Loading branch information
tbshag2 committed Sep 19, 2024
1 parent 38676c5 commit e91d1e4
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 37 deletions.
39 changes: 39 additions & 0 deletions docs/api/config/booking-locale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
sidebar_label: locale
title: locale
description: You can learn about the locale in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
---

# locale

### Description

@short: Optional. An object of a custom locale of Booking

### Usage

~~~jsx
locale?: object;
~~~

### Default config

By default, Booking uses the [English](/guides/localization/#default-locale) locale. You can set it to the custom locale as well.

:::tip
To change the current locale dynamically, you can use the [`setLocale()`](/api/methods/booking-setlocale-method) method
:::

### Example

~~~jsx
const { data } = getData();
const widget = new booking.Booking("#root", {
data,
locale: de,
});
~~~

**Related articles**:
- [setLocale()](/api/methods/booking-setlocale-booking)
- [Localization](/guides/localization)
42 changes: 42 additions & 0 deletions docs/api/methods/booking-setlocale-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
sidebar_label: setLocale()
title: setLocale() Method
description: You can learn about the setLocale() method in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
---

# setLocale()

### Description

@short: Applies a new locale to Booking

### Usage

~~~jsx
setLocale(null | locale?: object): void;
~~~

### Parameters

- `null` - (optional) resets to the default locale (English)
- `locale` - (optional) the object of data of the new locale to be applied

### Example

~~~jsx {}
// create Booking
const booking = new booking.Booking("#root", {
data,
// initial configuration parameters
});

// apply the "de" locale to Booking
booking.setLocale(de);

// apply the default locale to Booking
booking.setLocale(); // or setLocale(null);
~~~

**Related articles**:
- [locale](/api/config/booking-locale)
- [Localization](/guides/localization)
34 changes: 0 additions & 34 deletions docs/api/methods/booking_methodname_method.md

This file was deleted.

8 changes: 6 additions & 2 deletions docs/guides/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ Example:
To apply a custom locale, you need to:

- create a custom locale object (or modify the default one) and provide translations for all text labels (it can be any language you need)
- apply the new locale via its [`locale`](/api/config/locale-property) property or use the [`setLocale()`](/api/methods/setlocale-method) method
- apply the new locale via its [`locale`](/api/config/locale-property) property or use the [`setLocale()`](/api/methods/booking-setlocale-method) method

~~~jsx
// create Pivot
// create Booking
const widget = new booking.Booking("#root", {
data,
});
Expand All @@ -216,3 +216,7 @@ widget.setLocale(ko);
In this snippet you can see how to switch through the *EN* and *DE* locales:

<iframe src="" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>

**Related articles**:
- [locale](/api/config/booking-locale)
- [setLocale()](/api/methods/booking-setlocale-methods)
3 changes: 2 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
collapsible: true,
collapsed: true,
items: [
"api/methods/booking_methodname_method",
"api/methods/booking-setlocale-method",
]
},
// Booking internal methods
Expand Down Expand Up @@ -94,6 +94,7 @@ module.exports = {
"api/config/booking-filtershape",
"api/config/booking-formshape",
"api/config/booking-infoshape",
"api/config/booking-locale",
"api/config/booking-slotgap",
"api/config/booking-slotsize",
]
Expand Down

0 comments on commit e91d1e4

Please sign in to comment.