@@ -57,25 +57,25 @@ idrinth.chat = {
57
57
var promotionModes = [
58
58
{
59
59
chat : chat ,
60
- label : 'Ban User ' ,
60
+ label : 'chat.actions.banUser ' ,
61
61
rank : 'Banned' ,
62
62
requiredRank : 3
63
63
} ,
64
64
{
65
65
chat : chat ,
66
- label : 'Make Moderator ' ,
66
+ label : 'chat.actions.makeMod ' ,
67
67
rank : 'Mod' ,
68
68
requiredRank : 3
69
69
} ,
70
70
{
71
71
chat : chat ,
72
- label : 'Make Admin ' ,
72
+ label : 'chat.actions.makeAdmin ' ,
73
73
rank : 'Owner' ,
74
74
requiredRank : 4
75
75
} ,
76
76
{
77
77
chat : chat ,
78
- label : 'Make User ' ,
78
+ label : 'chat.actions.makeUser ' ,
79
79
rank : 'User' ,
80
80
requiredRank : 3
81
81
}
@@ -155,10 +155,10 @@ idrinth.chat = {
155
155
}
156
156
} ,
157
157
function ( reply ) {
158
- idrinth . core . alert ( this . getMsg ( 'modify.fail' ) ) ;
158
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.modify" ) ) ;
159
159
} ,
160
160
function ( reply ) {
161
- idrinth . core . alert ( this . getMsg ( 'modify.fail' ) ) ;
161
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.modify" ) ) ;
162
162
} ,
163
163
JSON . stringify ( {
164
164
chat : chat ,
@@ -314,7 +314,7 @@ idrinth.chat = {
314
314
( idrinth . settings . notification . mention && text . match ( new RegExp ( '(\s|^)' + idrinth . core . escapeRegExp ( idrinth . chat . users [ idrinth . chat . self ] . name ) + '(\s|$)' , 'i' ) ) !== null ) ||
315
315
( idrinth . settings . notification . raid && text . match ( / \{ [ A - Z ] { 2 } - R a i d / ) !== null ) ;
316
316
} catch ( e ) {
317
- idrinth . core . log ( e . getMessage ( ) ) ;
317
+ idrinth . core . log ( e . getMessage ( ) ) ;
318
318
return false ;
319
319
}
320
320
} ;
@@ -493,12 +493,13 @@ idrinth.chat = {
493
493
start : function ( ) {
494
494
var build = function ( ) {
495
495
var makeInput = function ( label ) {
496
+ var translation = idrinth . text . get ( label ) ;
496
497
return {
497
498
type : 'li' ,
498
499
children : [
499
500
{
500
501
type : 'label' ,
501
- content : label
502
+ content : translation === idrinth . text . data . default ? label : translation
502
503
} ,
503
504
{
504
505
type : 'input' ,
@@ -517,6 +518,7 @@ idrinth.chat = {
517
518
} ;
518
519
} ;
519
520
var makeButton = function ( label , onclick ) {
521
+ var translation = idrinth . text . get ( label ) ;
520
522
return {
521
523
type : 'li' ,
522
524
children : [
@@ -532,7 +534,7 @@ idrinth.chat = {
532
534
value : onclick
533
535
}
534
536
] ,
535
- content : label
537
+ content : translation === idrinth . text . data . default ? label : translation
536
538
}
537
539
]
538
540
} ;
@@ -581,29 +583,29 @@ idrinth.chat = {
581
583
children : [
582
584
{
583
585
type : 'h1' ,
584
- content : 'Chat'
586
+ content : idrinth . text . get ( "chat.ui.chat" )
585
587
} ,
586
588
{
587
589
type : 'p' ,
588
- content : 'This part of the script is optional, so logging in is unneeded for raid catching etc.'
590
+ content : idrinth . text . get ( "chat.message. optional" )
589
591
} , {
590
592
id : 'idrinth-chat-login' ,
591
593
children : [
592
594
{
593
595
type : 'h2' ,
594
- content : 'Account'
596
+ content : idrinth . text . get ( "chat.ui.account" )
595
597
} ,
596
598
{
597
599
type : 'p' ,
598
- content : 'This should not be the data for logging in on the related gaming site and the login does not need to match your ingame name - you can set a display name after the registration.'
600
+ content : idrinth . text . get ( "chat.message.invalid" )
599
601
} ,
600
602
{
601
603
type : 'ul' ,
602
604
css : 'settings' ,
603
605
children : [
604
606
makeInput ( 'Username' ) ,
605
607
makeInput ( 'Password' ) ,
606
- makeButton ( "Not logged in, click to login/register" , "idrinth.chat.login()" )
608
+ makeButton ( 'chat.message.offline' , "idrinth.chat.login()" )
607
609
]
608
610
}
609
611
]
@@ -612,15 +614,15 @@ idrinth.chat = {
612
614
children : [
613
615
{
614
616
type : 'h2' ,
615
- content : 'Join Chat'
617
+ content : idrinth . text . get ( "chat.ui.joinChat" )
616
618
} ,
617
619
{
618
620
type : 'ul' ,
619
621
css : 'settings' ,
620
622
children : [
621
623
makeInput ( 'Chat-ID' ) ,
622
624
makeInput ( 'Chat-Password' ) ,
623
- makeButton ( "Click to join additional chat" , "idrinth.chat.add()" )
625
+ makeButton ( ' chat.ui.createAddChat' , "idrinth.chat.add()" )
624
626
]
625
627
}
626
628
]
@@ -630,14 +632,14 @@ idrinth.chat = {
630
632
children : [
631
633
{
632
634
type : 'h2' ,
633
- content : 'Create Chat'
635
+ content : idrinth . text . get ( "chat.ui.createChat" )
634
636
} ,
635
637
{
636
638
type : 'ul' ,
637
639
css : 'settings' ,
638
640
children : [
639
641
makeInput ( "Name" ) ,
640
- makeButton ( "Click to create additional chat" , "idrinth.chat.create()" )
642
+ makeButton ( ' chat.ui.createAddChat' , "idrinth.chat.create()" )
641
643
]
642
644
}
643
645
]
@@ -646,7 +648,7 @@ idrinth.chat = {
646
648
children : [
647
649
{
648
650
type : '#text' ,
649
- content : 'More settings at '
651
+ content : idrinth . text . get ( "chat.ui.moreSettings" )
650
652
} ,
651
653
{
652
654
type : 'a' ,
@@ -672,7 +674,7 @@ idrinth.chat = {
672
674
children : [
673
675
{
674
676
type : '#text' ,
675
- content : 'Emoticons provided by '
677
+ content : idrinth . text . get ( "chat.ui.creditEmoticon" )
676
678
} ,
677
679
{
678
680
type : 'a' ,
@@ -744,29 +746,29 @@ idrinth.chat = {
744
746
'chat-service/create/' ,
745
747
idrinth . chat . joinCallback ,
746
748
function ( reply ) {
747
- idrinth . core . alert ( this . getMsg ( 'create.fail' ) ) ;
749
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.create" ) ) ;
748
750
} ,
749
751
function ( reply ) {
750
- idrinth . core . alert ( this . getMsg ( 'create.fail' ) ) ;
752
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.create" ) ) ;
751
753
} ,
752
754
document . getElementById ( 'idrinth-make-chat' ) . getElementsByTagName ( 'input' ) [ 0 ] . value
753
755
) ;
754
756
} ,
755
757
joinCallback : function ( reply ) {
756
758
if ( ! reply ) {
757
- idrinth . core . alert ( this . getMsg ( 'join.fail' ) ) ;
759
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.join" ) ) ;
758
760
return ;
759
761
}
760
762
reply = JSON . parse ( reply ) ;
761
763
if ( ! reply ) {
762
- idrinth . core . alert ( this . getMsg ( 'join.fail' ) ) ;
764
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.join" ) ) ;
763
765
return ;
764
766
}
765
767
if ( ! reply . success ) {
766
768
if ( reply . message ) {
767
769
idrinth . core . alert ( reply . message ) ;
768
770
} else {
769
- idrinth . core . alert ( this . getMsg ( 'join.notwork' ) ) ;
771
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.join" ) ) ;
770
772
}
771
773
return ;
772
774
}
@@ -782,10 +784,10 @@ idrinth.chat = {
782
784
'chat-service/join/' ,
783
785
idrinth . chat . joinCallback ,
784
786
function ( reply ) {
785
- idrinth . core . alert ( this . getMsg ( 'join.fail' ) ) ;
787
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.join" ) ) ;
786
788
} ,
787
789
function ( reply ) {
788
- idrinth . core . alert ( this . getMsg ( 'join.fail' ) ) ;
790
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.join" ) ) ;
789
791
} ,
790
792
JSON . stringify ( {
791
793
id : document . getElementById ( 'idrinth-add-chat' ) . getElementsByTagName ( 'input' ) [ 0 ] . value ,
@@ -825,16 +827,16 @@ idrinth.chat = {
825
827
} ,
826
828
loginCallback : function ( data ) {
827
829
if ( ! data ) {
828
- idrinth . core . alert ( idrinth . chat . getMsg ( 'login.fail' ) ) ;
830
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.login" ) ) ;
829
831
return ;
830
832
}
831
833
data = JSON . parse ( data ) ;
832
834
if ( ! data ) {
833
- idrinth . core . alert ( idrinth . chat . getMsg ( 'login.fail' ) ) ;
835
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.login" ) ) ;
834
836
return ;
835
837
}
836
838
if ( ! data . success && data . message && data [ 'allow-reg' ] ) {
837
- idrinth . core . confirm ( idrinth . chat . getMsg ( 'user. unknown' ) , 'idrinth.chat.register();' ) ;
839
+ idrinth . core . confirm ( idrinth . text . get ( "chat.message. unknown" ) , 'idrinth.chat.register();' ) ;
838
840
return ;
839
841
}
840
842
if ( ! data . success && data . message ) {
@@ -849,7 +851,7 @@ idrinth.chat = {
849
851
idrinth . chat . join ( data . data ) ;
850
852
return ;
851
853
}
852
- idrinth . core . alert ( idrinth . chat . getMsg ( 'login.fail' ) ) ;
854
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.login" ) ) ;
853
855
} ,
854
856
register : function ( ) {
855
857
this . loginActions ( 'register' ) ;
@@ -867,29 +869,29 @@ idrinth.chat = {
867
869
css : 'idrinth-hovering-box' ,
868
870
children : [ {
869
871
css : 'clipboard-copy' ,
870
- content : 'Copy Password&Id' ,
872
+ content : idrinth . text . get ( "chat.ui.copyIdPasswort" ) ,
871
873
type : 'li' ,
872
874
attributes : [ {
873
875
name : 'data-clipboard-text' ,
874
876
value : element . getAttribute ( 'title' )
875
877
} ]
876
878
} , {
877
- content : 'Leave Room' ,
879
+ content : idrinth . text . get ( "chat.ui.leaveRoom" ) ,
878
880
type : 'li' ,
879
881
attributes : [ {
880
882
name : 'onclick' ,
881
883
value : 'idrinth.chat.useroptions(' + element . getAttribute ( 'data-id' ) + ',' + idrinth . chat . self + ',\'Leave\');this.parentNode.parentNode.removeChild(this.parentNode);'
882
884
} ]
883
885
} , {
884
- content : 'Delete Room' ,
886
+ content : idrinth . text . get ( "chat.ui.deleteRoom" ) ,
885
887
type : 'li' ,
886
888
attributes : [ {
887
889
name : 'onclick' ,
888
890
value : 'idrinth.core.ajax.runHome(\'chat-service/delete/' + element . getAttribute ( 'data-id' ) + '/\',idrinth.core.alert,idrinth.core.alert,idrinth.core.alert);this.parentNode.parentNode.removeChild(this.parentNode);'
889
891
} ]
890
892
} , {
891
893
type : 'li' ,
892
- content : 'Close' ,
894
+ content : idrinth . text . get ( "chat.ui.close" ) ,
893
895
attributes : [ {
894
896
name : 'onclick' ,
895
897
value : 'this.parentNode.parentNode.removeChild(this.parentNode);'
@@ -930,20 +932,6 @@ idrinth.chat = {
930
932
element . innerHTML = '>>' ;
931
933
}
932
934
} ,
933
- getMsg : function ( key ) {
934
- var textKey = key || '' ;
935
- var text = {
936
- 'modify.fail' : 'Can\'t modify that user at the moment' ,
937
- 'create.fail' : 'Can\'t create at the moment' ,
938
- 'join.fail' : 'Can\'t join at the moment' ,
939
- 'join.notwork' : 'Joining didn\'t work' ,
940
- 'user.unknown' : 'The given username for dotd.idrinth.de is unknown, do you want to register it there?' ,
941
- 'login.fail' : 'Login failed in an unexpected way' ,
942
- 'default.error' : 'Unexpected error occurred. Please contact script developers'
943
- + ' (https://github.com/Idrinth/IDotD).'
944
- } ;
945
- return text . hasOwnProperty ( textKey ) ? text [ textKey ] : text [ 'default.error' ] ;
946
- } ,
947
935
loginActions : function ( key ) {
948
936
var chatLogin ,
949
937
success ,
@@ -953,7 +941,7 @@ idrinth.chat = {
953
941
'relogin' : 'chat-service/login/'
954
942
} ,
955
943
fail = function ( ) {
956
- idrinth . core . alert ( this . getMsg ( 'login.fail' ) ) ;
944
+ idrinth . core . alert ( idrinth . text . get ( "chat.error.login" ) ) ;
957
945
} ,
958
946
timeout = function ( ) {
959
947
window . setTimeout ( idrinth . chat . login , 1 ) ;
0 commit comments