Last Updated on : 2023-07-03 03:04:44download
Panel Multilingual BizBundle provides the capabilities to update and get panel language packs for smart products based on the integration with Smart Life App SDK. In the left-side navigation pane of Tuya IoT Development Platform, you can choose App > Multi-language > Product Language to manage multilingual entries of smart products.
Query the capabilities of the panel multilingual SDKs:
IPanelI18n i18nManager = ThingPanelI18nEntrance.getInstance();
Configure the following dependencies in build.gradle
:
dependencies {
// for panel i18n
implementation "com.thingclips.smart:thingsmart-sdk-i18n:2.0.1-cube.1 "
implementation "com.thingclips.smart:thingsmart-sdk-i18n-api:2.0.1-cube.1 "
// requested
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
$kotlin_version
indicates that you must customize the Kotlin version by yourself.
Updates the multilingual content of specific panels. A callback is executed to send a notification on a failed request.
API description
void updateI18n(I18nRequestParam requestParam, IThingResultCallback<Object> listener)
Parameters
Parameter | Description |
---|---|
requestParam | The parameters of the requested package. productId and i18nTime must be set. |
listener | The success or failure callback. |
Fields of I18nRequestParam
Field | Type | Description |
---|---|---|
productId | String | The product ID (PID). The devices with the same PID have the same schema data. You can call DeviceBean#getProductId to get the PID. |
productVer | String | The product version (productVer).You can call DeviceBean#getProductVer to get the productVer. |
i18nTime | Long | The multilingual timestamp of a product. You can call DeviceBean#getI18nTime to get the value. |
Example
public void updateI18n(String productId, long i18nTime){
I18nRequestParam param = new I18nRequestParam(productId, i18nTime);
ThingPanelI18nEntrance.getInstance().updateI18n(param, new IThingResultCallback<Object>() {
@Override
public void onSuccess(Object result) {
// The success callback.
v.updateSuccess();
}
@Override
public void onError(String errorCode, String errorMessage) {
// The failure callback.
v.updateFail(errorMessage);
}
});
}
Returns the cached panel multilingual content based on productId
,productVer
and i18nTime
. For example, to process multilingual content for a smart product, you can call multilingual API methods of the SDK to get multilingual content for all languages. After a panel is started, you can specify the target language and entry codes to get the desired multilingual content. Before the initial query of panel multilingual content, you must make API requests to update the content first.
API description
The data of Map
is returned in the key-value pair format. The primary key indicates the language, such as en
. The value of the primary key is still represented in the key-value pair format. The secondary key identifies an entry and its value is the text of the entry in the specified language.
Map<String, Map<String, Object>> getI18nMap(I18nRequestParam requestParam)
Parameters
Parameter | Description |
---|---|
requestParam | The parameters of the requested package. productId ,productVer and i18nTime must be set. |
Example
public void showI18n(){
long homeId = 1L;
// Returns the data of `deviceBean`.
DeviceBean deviceBean = ThingHomeSdk.newHomeInstance(homeId).getHomeBean().getDeviceList().get(0);
// Returns the product ID that matches `deviceBean`.
String productId = deviceBean.getProductId();
//Returns the product version that matches `deviceBean`.
String productVer = deviceBean.getProductVer();
// Returns the timestamp of the language pack.
long i18nTime = deviceBean.getI18nTime();
// Returns the map of the language pack for the specified PID.
Map<String, Map<String, Object>> contentMap = ThingPanelI18nEntrance.getInstance().getI18nMap(new I18nRequestParam(productId, productVer,i18nTime));
for (Map.Entry<String, Map<String, Object>> langEntry : contentMap.entrySet()) {
// `key` indicates the language.
String lang = langEntry.getKey();
for(Map.Entry<String, Object> entry : langEntry.getValue().entrySet()){
// `key` indicates the key of the target entry.
String key = entry.getKey();
// `value` indicates the multilingual content of the target entry in the specified language
String i18nValue = (String) entry.getValue();
}
}
// The following example shows the `power_tip` entry in English.
String lang = "en";
String key = "power_tip";
String i18nValue = (String) contentMap.get(lang).get(key);
}
Sample response
{
"en":{
"cancel":"Cancel",
"removeFailed":"Failed to remove the device",
"TYTimer_endTimeTilte":"End Time",
"power_tip":"Tap to start",
"openBle":"Open Bluetooth",
"Edit":"Edit",
"setting":"Setting",
"TYTimer_editTimer":"Edit",
"mode_white":"White Mode",
"8ea247cc_label":"Scene",
"TYTimer_dayOnce":"Once",
"dp_battery":"BATTERY",
"quickop_dp_temp_value":"Color Temp",
"scene_leisure":"Leisure",
"d0ba1d23_label":"White",
"backToHome":"Back Home",
"TYTimer_dayEvery":"EveryDay",
"day8":"Once",
"day6":"Sat",
"day7":"Everyday",
"day4":"Thur",
"day5":"Fri",
"day2":"Tues",
"day3":"Wed",
"day0":"Sun",
"day1":"Mon"
},
"zh_Hans_CN":{
"cancel":"取消",
"removeFailed":"删除失败",
"TYTimer_endTimeTilte":"结束时间",
"power_tip":"点击开灯",
"openBle":"开启系统蓝牙",
"Edit":"编辑",
"setting":"设置",
"TYTimer_editTimer":"编辑",
"mode_white":"白光模式",
"8ea247cc_label":"情景",
"TYTimer_dayOnce":"仅一次",
"dp_battery":"剩余电量",
"quickop_dp_temp_value":"冷暖值",
"scene_leisure":"休闲",
"d0ba1d23_label":"白光",
"backToHome":"返回首页",
"TYTimer_dayEvery":"每天",
"day8":"仅此一次",
"day6":"星期六",
"day7":"每天",
"day4":"星期四",
"day5":"星期五",
"day2":"星期二",
"day3":"星期三",
"day0":"星期天",
"day1":"星期一"
}
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback