Feature: multi language (VI, EN, JA)

CR: sonh (fake)
This commit is contained in:
2021-08-23 15:19:49 +07:00
parent 7057e5b35c
commit eb88996797
37 changed files with 788 additions and 327 deletions

BIN
web/images/lang/en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
web/images/lang/jp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
web/images/lang/vi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@@ -1,8 +1,8 @@
<?php
// comment out the following two lines when deployed to production
//defined('YII_DEBUG') or define('YII_DEBUG', true);
//defined('YII_ENV') or define('YII_ENV', 'dev');
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

View File

@@ -35,17 +35,17 @@ function _close() {
function _save(e) {
var code = $("select[name='Code']").val();
if (code === "") {
alert("Hãy chọn đối tượng!");
alert($("input[name='HAY_CHON_DOI_TUONG']").val());
return;
}
var name = $("input[name='Name']").val();
if (name === "") {
alert("Hãy nhập tên!");
alert($("input[name='HAY_NHAP_TEN']").val());
return;
}
var abbreviated_name = $("input[name='AbbreviatedName']").val();
if (abbreviated_name === "") {
alert("Hãy nhập tên hiển thị!");
alert($("input[name='HAY_NHAP_TEN_HIEN_THI']").val());
return;
}
common.modalBlock(true);
@@ -66,7 +66,7 @@ function _save(e) {
success: function (data) {
common.modalBlock(false);
if (data.status) {
alert("Đã thêm dữ liệu thành công!");
alert($("input[name='CAP_NHAT_DU_LIEU_THANH_CONG']").val());
window.location.reload(true);
} else {
alert(data.text);

View File

@@ -155,7 +155,7 @@ common.modalAlert = function (text, cls, link) {
}
};
common.ajaxError = function () {
common.modalAlert("Có lỗi xảy ra, có thể do đường truyền mạng, xin vui lòng thử lại!", "danger", "");
common.modalAlert($("input[name='CO_LOI_XAY_RA_HAY_THU_LAI']").val(), "danger", "");
};
common.btnUpload = function (mUrl, className, extension, fileSize) {
var fData = {
@@ -310,14 +310,14 @@ common.reset = function (e) {
if ($("input[name='ResetDevice']").is(':checked'))
resetDevice = true;
if (!deleteDB && !resetDevice) {
alert("Hãy lựa chọn thao tác!");
alert($("input[name='HAY_LUA_CHON_THAO_TAC']").val());
return;
}
var confirmText = "";
if (deleteDB)
confirmText = "Bạn có chắc chắn muốn xóa dữ liệu lưu trữ trong thiết bị không?";
confirmText = $("input[name='DELETE_DB_CONFIRM']").val();
if (resetDevice)
confirmText = "Bạn có chắc chắn muốn reset cấu hình thiết bị không?";
confirmText = $("input[name='RESET_DB_CONFIRM']").val();
if (confirm(confirmText)) {
common.modalBlock(true);
$.ajax({
@@ -342,6 +342,17 @@ common.validateIp = function (Ip) {
return true;
}
return false;
};
common.changeLanguage = function (e) {
$.ajax({
url: $(e).attr("href"),
type: 'POST',
success: function (data) {
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
/**
* =========================

View File

@@ -4,12 +4,12 @@ $(function () {
function saveStep1(e) {
var servermqtt = $("input[name='servermqtt']").val();
if (servermqtt === "") {
alert("Hãy nhập thông tin!");
alert($("input[name='HAY_NHAP_THONG_TIN']").val());
return;
}
var url = $("input[name='url']").val();
if (url === "") {
alert("Hãy nhập thông tin!");
alert($("input[name='HAY_NHAP_THONG_TIN']").val());
return;
}
common.modalBlock(true);
@@ -34,7 +34,7 @@ function saveStep1(e) {
if (data.text === "error") {
c++;
if (c == 5) {
alert("Box chưa được đăng kí trên CMS!");
alert($("input[name='BOX_CHUA_DUOC_DANG_KI_TREN_CMS']").val());
window.location.reload(true);
}
} else {
@@ -75,11 +75,10 @@ function saveStep2(e) {
config: cfg
},
success: function (data) {
if (data) {
notification.success("Đã lưu cấu hình!", 2000);
} else {
notification.success("Lưu cấu hình thất bại!", 2000);
}
if (data)
notification.success($("input[name='DA_LUU_CAU_HINH']").val(), 2000);
else
notification.success($("input[name='LUU_CAU_HINH_THAT_BAI']").val(), 2000);
common.modalBlock(false);
},
error: function (jqXHR, textStatus, errorThrown) {
@@ -93,7 +92,7 @@ function SaveConfigDevice(e) {
var server_api = $("input[name='server_api']").val();
var device_id = $("input[name='device_id']").val();
if (server_api === "" || device_id === "") {
alert("Hãy nhập đủ thông tin");
alert($("input[name='HAY_NHAP_THONG_TIN']").val());
return;
}
common.modalBlock(true);
@@ -105,11 +104,10 @@ function SaveConfigDevice(e) {
device_id: device_id
},
success: function (data) {
if (data) {
notification.success("Đã lưu cấu hình!", 2000);
} else {
notification.success("Lưu cấu hình thất bại!", 2000);
}
if (data)
notification.success($("input[name='DA_LUU_CAU_HINH']").val(), 2000);
else
notification.success($("input[name='LUU_CAU_HINH_THAT_BAI']").val(), 2000);
common.modalBlock(false);
},
error: function (jqXHR, textStatus, errorThrown) {

View File

@@ -22,7 +22,7 @@ function _useFeature(e) {
success: function (data) {
common.modalBlock(false);
if (data.status) {
alert("Đã thêm hình ảnh mẫu!");
alert($("input[name='DA_THEM_HINH_ANH_MAU']").val());
} else {
alert(data.text);
}

View File

@@ -87,17 +87,17 @@ function _formModified(e) {
function _update(e) {
var code = $("select[name='Code']").val();
if (code === "") {
alert("Hãy chọn đối tượng!");
alert($("input[name='HAY_CHON_DOI_TUONG']").val());
return;
}
var name = $("input[name='Name']").val();
if (name === "") {
alert("Hãy nhập tên!");
alert($("input[name='HAY_NHAP_TEN']").val());
return;
}
var abbreviated_name = $("input[name='AbbreviatedName']").val();
if (abbreviated_name === "") {
alert("Hãy nhập tên hiển thị!");
alert($("input[name='HAY_NHAP_TEN_HIEN_THI']").val());
return;
}
common.modalBlock(true);
@@ -119,10 +119,10 @@ function _update(e) {
success: function (data) {
common.modalBlock(false);
if (data) {
alert("Cập nhật dữ liệu thành công!");
alert($("input[name='CAP_NHAT_DU_LIEU_THANH_CONG']").val());
window.location.reload(true);
} else
alert("Mã đối tượng đã tồn tại!");
alert($("input[name='MA_DOI_TUONG_DA_TON_TAI']").val());
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
@@ -132,7 +132,7 @@ function _update(e) {
}
function _delete(e) {
if (confirm("Bạn có chắc chắn muốn xóa không?")) {
if (confirm($("input[name='DELETE_CONFIRM']").val())) {
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
@@ -152,7 +152,7 @@ function _delete(e) {
}
function _deleteFeature(e) {
if (confirm("Bạn có chắc chắn muốn xóa ảnh này không?")) {
if (confirm($("input[name='DELETE_CONFIRM']").val())) {
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
@@ -183,7 +183,7 @@ function checkAll(status) {
function batchDelete(e) {
var check = $(".delete-choose");
if (check.length == 0) {
alert("Hãy chọn dữ liệu để xóa!");
alert($("input[name='HAY_CHON_DU_LIEU_DE_XOA']").val());
return;
}
var lists = [];
@@ -191,7 +191,7 @@ function batchDelete(e) {
if ($(this).attr("data-id") !== "")
lists.push($(this).attr("data-id"));
});
if (confirm("Bạn có chắc chắn muốn xóa không?")) {
if (confirm($("input[name='DELETE_CONFIRM']").val())) {
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
@@ -200,7 +200,7 @@ function batchDelete(e) {
lists: lists
},
success: function (data) {
alert("Đã xóa dữ liệu!");
alert($("input[name='DA_XOA_DU_LIEU']").val());
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
@@ -239,7 +239,7 @@ function btnImage() {
fileExtension: '.png,.jpg,.jpeg,.gif',
fileSizeLimit: 1,
classes: 'btn btn-default btn-xs',
fakeInputContent: '<span class=\'fa fa-file-image-o\'></span> Chọn hình ảnh',
fakeInputContent: '<span class=\'fa fa-file-image-o\'></span> ' + $("input[name='CHON_HINH_ANH']").val(),
onUploaded: function (data) {
var res = JSON.parse(data);
if (res.status) {
@@ -247,7 +247,7 @@ function btnImage() {
$("input[name='AnhNhanVienUrl']").val(res.url);
common.uploadBlock(false);
} else {
alert("Hình ảnh không nhận diện được khuôn mặt");
alert($("input[name='HINH_ANH_KHONG_NHAN_DIEN_DUOC_KHUON_MAT']").val());
}
}
}).addInstance('AnhNhanVien');
@@ -256,17 +256,17 @@ function btnImage() {
function _create(e) {
var code = $("select[name='Code']").val();
if (code === "") {
alert("Hãy chọn đối tượng!");
alert($("input[name='HAY_CHON_DOI_TUONG']").val());
return;
}
var name = $("input[name='Name']").val();
if (name === "") {
alert("Hãy nhập tên!");
alert($("input[name='HAY_NHAP_TEN']").val());
return;
}
var image = $("input[name='AnhNhanVienUrl']").val();
if (image === "") {
alert("Hãy tải lên hình ảnh");
alert($("input[name='HAY_TAI_LEN_HINH_ANH']").val());
return;
}
common.modalBlock(true);
@@ -286,10 +286,10 @@ function _create(e) {
success: function (data) {
common.modalBlock(false);
if (data.status) {
alert("Cập nhật dữ liệu thành công!");
alert($("input[name='CAP_NHAT_DU_LIEU_THANH_CONG']").val());
window.location.reload(true);
} else
alert("Mã đối tượng đã tồn tại!");
alert($("input[name='MA_DOI_TUONG_DA_TON_TAI']").val());
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
@@ -301,11 +301,11 @@ function _create(e) {
function _syncForm(e) {
var ip = $("input[name='SyncIP']").val();
if (ip === "") {
common.error("ip", "Hãy nhập địa chỉ ip thiết bị muốn đồng bộ");
common.error("ip", $("input[name='HAY_NHAP_DIA_CHI_IP_DONG_BO']").val());
return;
}
if (!common.validateIp(ip)) {
common.error("ip", "Sai định dạng ip");
common.error("ip", $("input[name='SAI_DINH_DANG_IP']").val());
return;
}
common.success("ip");
@@ -320,12 +320,12 @@ function _syncForm(e) {
common.modalBlock(false);
common.modalOpenFullScreen(data.form, data.title);
$("#filter-from-server").select2({
placeholder: "Tìm kiếm theo ID hoặc tên"
placeholder: $("input[name='TIM_KIEM_THEO_ID_HOAC_TEN']").val()
});
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
alert("Không có kết nối tới thiết bị");
alert($("input[name='KHONG_CO_KET_NOI_TOI_THIET_BI']").val());
}
});
}
@@ -367,7 +367,7 @@ function _sync() {
lists.push($(this).attr("data-id"));
});
if (lists.length == 0) {
alert("Không có dữ liệu đồng bộ!");
alert($("input[name='KHONG_CO_DU_LIEU_DONG_BO']").val());
return;
}
common.modalBlock(true);
@@ -408,7 +408,7 @@ function syncFeatureFromDevice(id, fullData) {
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
alert("Mất kết nối tới thiết bị");
alert($("input[name='KHONG_CO_KET_NOI_TOI_THIET_BI']").val());
}
});
}
@@ -422,7 +422,7 @@ function _syncFromServerForm(e) {
common.modalBlock(false);
common.modalOpenFullScreen(data.form, data.title);
$("#filter-from-server").select2({
placeholder: "Tìm kiếm theo ID hoặc tên"
placeholder: $("input[name='TIM_KIEM_THEO_ID_HOAC_TEN']").val()
});
},
error: function (jqXHR, textStatus, errorThrown) {
@@ -439,7 +439,7 @@ function _syncFromServer() {
lists.push(JSON.parse($("#full-data-" + id).html()));
});
if (lists.length == 0) {
alert("Không có dữ liệu đồng bộ!");
alert($("input[name='KHONG_CO_DU_LIEU_DONG_BO']").val());
return;
}
common.modalBlock(true);
@@ -526,7 +526,7 @@ function _syncToServerForm(e) {
common.modalBlock(false);
common.modalOpenFullScreen(data.form, data.title);
$("#filter-from-server").select2({
placeholder: "Tìm kiếm theo ID hoặc tên"
placeholder: $("input[name='TIM_KIEM_THEO_ID_HOAC_TEN']").val()
});
},
error: function (jqXHR, textStatus, errorThrown) {
@@ -544,7 +544,7 @@ function _syncToServer() {
lists.push($(this).attr("data-id"));
});
if (lists.length == 0) {
alert("Không có dữ liệu đồng bộ!");
alert($("input[name='KHONG_CO_DU_LIEU_DONG_BO']").val());
return;
}
common.modalBlock(true);
@@ -576,7 +576,7 @@ function syncFeatureToServer(id, fullData) {
if (percent >= 100) {
common.modalBlock(false);
setTimeout(function () {
alert("Đồng bộ dữ liệu hoàn thành");
alert($("input[name='DONG_BO_DU_LIEU_HOAN_THANH']").val());
window.location.reload(true);
}, 2000)
} else {