check browser locale and add locale setting to profile
This commit is contained in:
parent
315757ff8e
commit
7490e10882
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
import injectTapEventPlugin from 'react-tap-event-plugin';
|
import injectTapEventPlugin from 'react-tap-event-plugin';
|
||||||
import UrlHandler from './url.handler';
|
import UrlHandler from './url.handler';
|
||||||
|
import addLocaleKorean from './locale/locale.constant-ko';
|
||||||
|
|
||||||
/* eslint-disable import/no-unresolved, import/default */
|
/* eslint-disable import/no-unresolved, import/default */
|
||||||
|
|
||||||
@ -48,6 +49,14 @@ export default function AppConfig($provide,
|
|||||||
$translateProvider.useMissingTranslationHandlerLog();
|
$translateProvider.useMissingTranslationHandlerLog();
|
||||||
$translateProvider.addInterpolation('$translateMessageFormatInterpolation');
|
$translateProvider.addInterpolation('$translateMessageFormatInterpolation');
|
||||||
|
|
||||||
|
addLocaleKorean(locales);
|
||||||
|
var $window = angular.injector(['ng']).get('$window');
|
||||||
|
var lang = $window.navigator.language || $window.navigator.userLanguage;
|
||||||
|
if (lang === 'ko') {
|
||||||
|
$translateProvider.useSanitizeValueStrategy(null);
|
||||||
|
$translateProvider.preferredLanguage('ko_KR');
|
||||||
|
}
|
||||||
|
|
||||||
for (var langKey in locales) {
|
for (var langKey in locales) {
|
||||||
var translationTable = locales[langKey];
|
var translationTable = locales[langKey];
|
||||||
$translateProvider.translations(langKey, translationTable);
|
$translateProvider.translations(langKey, translationTable);
|
||||||
|
|||||||
@ -14,16 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default angular.module('thingsboard.locale', [])
|
export default function addLocaleKorean(locales) {
|
||||||
.constant('locales',
|
var ko_KR = {
|
||||||
{
|
|
||||||
'ko_KR': {
|
|
||||||
"access": {
|
"access": {
|
||||||
"unauthorized": "권한 없음.",
|
"unauthorized": "권한 없음.",
|
||||||
"unauthorized-access": "허가되지 않은 접근",
|
"unauthorized-access": "허가되지 않은 접근",
|
||||||
"unauthorized-access-text": "이 리소스에 접근하려면 로그인해야 합니다!",
|
"unauthorized-access-text": "이 리소스에 접근하려면 로그인해야 합니다!",
|
||||||
"access-forbidden": "접근 금지",
|
"access-forbidden": "접근 금지",
|
||||||
"access-forbidden-text": "접근 권한이 없습니다.!<br/> 만일 이 페이지에 계속 접근하려면 다른 사용자로 로그인 하세요.",
|
"access-forbidden-text": "접근 권한이 없습니다.!<br> 만일 이 페이지에 계속 접근하려면 다른 사용자로 로그인 하세요.",
|
||||||
"refresh-token-expired": "세션이 만료되었습니다.",
|
"refresh-token-expired": "세션이 만료되었습니다.",
|
||||||
"refresh-token-failed": "세션을 새로 고칠 수 없습니다."
|
"refresh-token-failed": "세션을 새로 고칠 수 없습니다."
|
||||||
},
|
},
|
||||||
@ -264,8 +262,7 @@ export default angular.module('thingsboard.locale', [])
|
|||||||
"close-toolbar": "툴바 닫기",
|
"close-toolbar": "툴바 닫기",
|
||||||
"configuration-error": "구성 오류",
|
"configuration-error": "구성 오류",
|
||||||
"alias-resolution-error-title": "대시보드 앨리어스 구성 오류",
|
"alias-resolution-error-title": "대시보드 앨리어스 구성 오류",
|
||||||
"invalid-aliases-config": "일부 앨리어스 필터와 일치하는 디바이스를 찾을 수 없습니다.<br/>" +
|
"invalid-aliases-config": "일부 앨리어스 필터와 일치하는 디바이스를 찾을 수 없습니다.<br>이 문제를 해결하려면 관리자에게 문의하십시오.",
|
||||||
"이 문제를 해결하려면 관리자에게 문의하십시오.",
|
|
||||||
"select-devices": "디바이스 선택",
|
"select-devices": "디바이스 선택",
|
||||||
"assignedToCustomer": "커스터머에 할당됨"
|
"assignedToCustomer": "커스터머에 할당됨"
|
||||||
},
|
},
|
||||||
@ -774,7 +771,12 @@ export default angular.module('thingsboard.locale', [])
|
|||||||
"create-new-widget-type": "새로운 위젯 타입 생성",
|
"create-new-widget-type": "새로운 위젯 타입 생성",
|
||||||
"widget-type-file": "위젯 타입 파일",
|
"widget-type-file": "위젯 타입 파일",
|
||||||
"invalid-widget-type-file-error": "위젯 타입을 가져오기 할 수 없습니다.: 잘못된 위젯 타입 데이터 구조입니다."
|
"invalid-widget-type-file-error": "위젯 타입을 가져오기 할 수 없습니다.: 잘못된 위젯 타입 데이터 구조입니다."
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"language": "언어",
|
||||||
|
"en_US": "영어",
|
||||||
|
"ko_KR": "한글"
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
angular.extend(locales, {'ko_KR': ko_KR});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
).name;
|
|
||||||
@ -774,6 +774,11 @@ export default angular.module('thingsboard.locale', [])
|
|||||||
"create-new-widget-type": "Create new widget type",
|
"create-new-widget-type": "Create new widget type",
|
||||||
"widget-type-file": "Widget type file",
|
"widget-type-file": "Widget type file",
|
||||||
"invalid-widget-type-file-error": "Unable to import widget type: Invalid widget type data structure."
|
"invalid-widget-type-file-error": "Unable to import widget type: Invalid widget type data structure."
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"language": "Language",
|
||||||
|
"en_US": "English",
|
||||||
|
"ko_KR": "Korean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,25 +20,29 @@ import changePasswordTemplate from './change-password.tpl.html';
|
|||||||
/* eslint-enable import/no-unresolved, import/default */
|
/* eslint-enable import/no-unresolved, import/default */
|
||||||
|
|
||||||
/*@ngInject*/
|
/*@ngInject*/
|
||||||
export default function ProfileController(userService, $scope, $document, $mdDialog) {
|
export default function ProfileController(userService, $scope, $document, $mdDialog, $translate) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
vm.profileUser = {};
|
vm.profileUser = {};
|
||||||
|
|
||||||
vm.save = save;
|
vm.save = save;
|
||||||
vm.changePassword = changePassword;
|
vm.changePassword = changePassword;
|
||||||
|
vm.languageList = {en_US: {value: "en_US", name: "language.en_US"}, ko_KR: {value : "ko_KR", name: "language.ko_KR"}};
|
||||||
|
|
||||||
loadProfile();
|
loadProfile();
|
||||||
|
|
||||||
function loadProfile() {
|
function loadProfile() {
|
||||||
userService.getUser(userService.getCurrentUser().userId).then(function success(user) {
|
userService.getUser(userService.getCurrentUser().userId).then(function success(user) {
|
||||||
vm.profileUser = user;
|
vm.profileUser = user;
|
||||||
|
vm.profileUser.lang = $translate.use();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
userService.saveUser(vm.profileUser).then(function success(user) {
|
userService.saveUser(vm.profileUser).then(function success(user) {
|
||||||
|
$translate.use(vm.profileUser.lang);
|
||||||
vm.profileUser = user;
|
vm.profileUser = user;
|
||||||
|
vm.profileUser.lang = $translate.use();
|
||||||
$scope.theForm.$setPristine();
|
$scope.theForm.$setPristine();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,14 @@
|
|||||||
<label translate>user.last-name</label>
|
<label translate>user.last-name</label>
|
||||||
<input name="lastName" ng-model="vm.profileUser.lastName">
|
<input name="lastName" ng-model="vm.profileUser.lastName">
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
|
<md-input-container class="md-block">
|
||||||
|
<label translate>language.language</label>
|
||||||
|
<md-select name="language" ng-model="vm.profileUser.lang">
|
||||||
|
<md-option ng-repeat="lang in vm.languageList" ng-value="lang.value">
|
||||||
|
{{lang.name | translate}}
|
||||||
|
</md-option>
|
||||||
|
</md-select>
|
||||||
|
</md-input-container>
|
||||||
<md-button ng-disabled="loading" ng-click="vm.changePassword($event)"
|
<md-button ng-disabled="loading" ng-click="vm.changePassword($event)"
|
||||||
class="md-raised md-primary">{{ 'profile.change-password' | translate }}
|
class="md-raised md-primary">{{ 'profile.change-password' | translate }}
|
||||||
</md-button>
|
</md-button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user