Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit 3d58749

Browse files
authored
Merge pull request #182 from Idrinth/ardenian
Ardenian
2 parents c615823 + 7674040 commit 3d58749

File tree

6 files changed

+252
-99
lines changed

6 files changed

+252
-99
lines changed

Diff for: languages/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

Diff for: src/mods/chat.js

+38-50
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,25 @@ idrinth.chat = {
5757
var promotionModes = [
5858
{
5959
chat: chat,
60-
label: 'Ban User',
60+
label: 'chat.actions.banUser',
6161
rank: 'Banned',
6262
requiredRank: 3
6363
},
6464
{
6565
chat: chat,
66-
label: 'Make Moderator',
66+
label: 'chat.actions.makeMod',
6767
rank: 'Mod',
6868
requiredRank: 3
6969
},
7070
{
7171
chat: chat,
72-
label: 'Make Admin',
72+
label: 'chat.actions.makeAdmin',
7373
rank: 'Owner',
7474
requiredRank: 4
7575
},
7676
{
7777
chat: chat,
78-
label: 'Make User',
78+
label: 'chat.actions.makeUser',
7979
rank: 'User',
8080
requiredRank: 3
8181
}
@@ -155,10 +155,10 @@ idrinth.chat = {
155155
}
156156
},
157157
function ( reply ) {
158-
idrinth.core.alert ( this.getMsg ( 'modify.fail' ) );
158+
idrinth.core.alert ( idrinth.text.get ( "chat.error.modify" ) );
159159
},
160160
function ( reply ) {
161-
idrinth.core.alert ( this.getMsg ( 'modify.fail' ) );
161+
idrinth.core.alert ( idrinth.text.get ( "chat.error.modify" ) );
162162
},
163163
JSON.stringify ( {
164164
chat: chat,
@@ -314,7 +314,7 @@ idrinth.chat = {
314314
( idrinth.settings.notification.mention && text.match ( new RegExp ( '(\s|^)' + idrinth.core.escapeRegExp ( idrinth.chat.users[idrinth.chat.self].name ) + '(\s|$)', 'i' ) ) !== null ) ||
315315
( idrinth.settings.notification.raid && text.match ( /\{[A-Z]{2}-Raid / ) !== null );
316316
} catch ( e ) {
317-
idrinth.core.log ( e.getMessage ( ) );
317+
idrinth.core.log ( e.getMessage () );
318318
return false;
319319
}
320320
};
@@ -493,12 +493,13 @@ idrinth.chat = {
493493
start: function () {
494494
var build = function () {
495495
var makeInput = function ( label ) {
496+
var translation = idrinth.text.get( label );
496497
return {
497498
type: 'li',
498499
children: [
499500
{
500501
type: 'label',
501-
content: label
502+
content: translation === idrinth.text.data.default ? label : translation
502503
},
503504
{
504505
type: 'input',
@@ -517,6 +518,7 @@ idrinth.chat = {
517518
};
518519
};
519520
var makeButton = function ( label, onclick ) {
521+
var translation = idrinth.text.get( label );
520522
return {
521523
type: 'li',
522524
children: [
@@ -532,7 +534,7 @@ idrinth.chat = {
532534
value: onclick
533535
}
534536
],
535-
content: label
537+
content: translation === idrinth.text.data.default ? label : translation
536538
}
537539
]
538540
};
@@ -581,29 +583,29 @@ idrinth.chat = {
581583
children: [
582584
{
583585
type: 'h1',
584-
content: 'Chat'
586+
content: idrinth.text.get ( "chat.ui.chat" )
585587
},
586588
{
587589
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" )
589591
}, {
590592
id: 'idrinth-chat-login',
591593
children: [
592594
{
593595
type: 'h2',
594-
content: 'Account'
596+
content: idrinth.text.get ( "chat.ui.account" )
595597
},
596598
{
597599
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" )
599601
},
600602
{
601603
type: 'ul',
602604
css: 'settings',
603605
children: [
604606
makeInput ( 'Username' ),
605607
makeInput ( 'Password' ),
606-
makeButton ( "Not logged in, click to login/register", "idrinth.chat.login()" )
608+
makeButton ( 'chat.message.offline', "idrinth.chat.login()" )
607609
]
608610
}
609611
]
@@ -612,15 +614,15 @@ idrinth.chat = {
612614
children: [
613615
{
614616
type: 'h2',
615-
content: 'Join Chat'
617+
content: idrinth.text.get ( "chat.ui.joinChat" )
616618
},
617619
{
618620
type: 'ul',
619621
css: 'settings',
620622
children: [
621623
makeInput ( 'Chat-ID' ),
622624
makeInput ( 'Chat-Password' ),
623-
makeButton ( "Click to join additional chat", "idrinth.chat.add()" )
625+
makeButton ( 'chat.ui.createAddChat', "idrinth.chat.add()" )
624626
]
625627
}
626628
]
@@ -630,14 +632,14 @@ idrinth.chat = {
630632
children: [
631633
{
632634
type: 'h2',
633-
content: 'Create Chat'
635+
content: idrinth.text.get ( "chat.ui.createChat" )
634636
},
635637
{
636638
type: 'ul',
637639
css: 'settings',
638640
children: [
639641
makeInput ( "Name" ),
640-
makeButton ( "Click to create additional chat", "idrinth.chat.create()" )
642+
makeButton ( 'chat.ui.createAddChat', "idrinth.chat.create()" )
641643
]
642644
}
643645
]
@@ -646,7 +648,7 @@ idrinth.chat = {
646648
children: [
647649
{
648650
type: '#text',
649-
content: 'More settings at '
651+
content: idrinth.text.get ( "chat.ui.moreSettings" )
650652
},
651653
{
652654
type: 'a',
@@ -672,7 +674,7 @@ idrinth.chat = {
672674
children: [
673675
{
674676
type: '#text',
675-
content: 'Emoticons provided by '
677+
content: idrinth.text.get ( "chat.ui.creditEmoticon" )
676678
},
677679
{
678680
type: 'a',
@@ -744,29 +746,29 @@ idrinth.chat = {
744746
'chat-service/create/',
745747
idrinth.chat.joinCallback,
746748
function ( reply ) {
747-
idrinth.core.alert ( this.getMsg ( 'create.fail' ) );
749+
idrinth.core.alert ( idrinth.text.get ( "chat.error.create" ) );
748750
},
749751
function ( reply ) {
750-
idrinth.core.alert ( this.getMsg ( 'create.fail' ) );
752+
idrinth.core.alert ( idrinth.text.get ( "chat.error.create" ) );
751753
},
752754
document.getElementById ( 'idrinth-make-chat' ).getElementsByTagName ( 'input' )[0].value
753755
);
754756
},
755757
joinCallback: function ( reply ) {
756758
if ( !reply ) {
757-
idrinth.core.alert ( this.getMsg ( 'join.fail' ) );
759+
idrinth.core.alert ( idrinth.text.get ( "chat.error.join" ) );
758760
return;
759761
}
760762
reply = JSON.parse ( reply );
761763
if ( !reply ) {
762-
idrinth.core.alert ( this.getMsg ( 'join.fail' ) );
764+
idrinth.core.alert ( idrinth.text.get ( "chat.error.join" ) );
763765
return;
764766
}
765767
if ( !reply.success ) {
766768
if ( reply.message ) {
767769
idrinth.core.alert ( reply.message );
768770
} else {
769-
idrinth.core.alert ( this.getMsg ( 'join.notwork' ) );
771+
idrinth.core.alert ( idrinth.text.get ( "chat.error.join" ) );
770772
}
771773
return;
772774
}
@@ -782,10 +784,10 @@ idrinth.chat = {
782784
'chat-service/join/',
783785
idrinth.chat.joinCallback,
784786
function ( reply ) {
785-
idrinth.core.alert ( this.getMsg ( 'join.fail' ) );
787+
idrinth.core.alert ( idrinth.text.get ( "chat.error.join" ) );
786788
},
787789
function ( reply ) {
788-
idrinth.core.alert ( this.getMsg ( 'join.fail' ) );
790+
idrinth.core.alert ( idrinth.text.get ( "chat.error.join" ) );
789791
},
790792
JSON.stringify ( {
791793
id: document.getElementById ( 'idrinth-add-chat' ).getElementsByTagName ( 'input' )[0].value,
@@ -825,16 +827,16 @@ idrinth.chat = {
825827
},
826828
loginCallback: function ( data ) {
827829
if ( !data ) {
828-
idrinth.core.alert ( idrinth.chat.getMsg ( 'login.fail' ) );
830+
idrinth.core.alert ( idrinth.text.get ( "chat.error.login" ) );
829831
return;
830832
}
831833
data = JSON.parse ( data );
832834
if ( !data ) {
833-
idrinth.core.alert ( idrinth.chat.getMsg ( 'login.fail' ) );
835+
idrinth.core.alert ( idrinth.text.get ( "chat.error.login" ) );
834836
return;
835837
}
836838
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();' );
838840
return;
839841
}
840842
if ( !data.success && data.message ) {
@@ -849,7 +851,7 @@ idrinth.chat = {
849851
idrinth.chat.join ( data.data );
850852
return;
851853
}
852-
idrinth.core.alert ( idrinth.chat.getMsg ( 'login.fail' ) );
854+
idrinth.core.alert ( idrinth.text.get ( "chat.error.login" ) );
853855
},
854856
register: function () {
855857
this.loginActions ( 'register' );
@@ -867,29 +869,29 @@ idrinth.chat = {
867869
css: 'idrinth-hovering-box',
868870
children: [ {
869871
css: 'clipboard-copy',
870-
content: 'Copy Password&Id',
872+
content: idrinth.text.get ( "chat.ui.copyIdPasswort" ),
871873
type: 'li',
872874
attributes: [ {
873875
name: 'data-clipboard-text',
874876
value: element.getAttribute ( 'title' )
875877
} ]
876878
}, {
877-
content: 'Leave Room',
879+
content: idrinth.text.get ( "chat.ui.leaveRoom" ),
878880
type: 'li',
879881
attributes: [ {
880882
name: 'onclick',
881883
value: 'idrinth.chat.useroptions(' + element.getAttribute ( 'data-id' ) + ',' + idrinth.chat.self + ',\'Leave\');this.parentNode.parentNode.removeChild(this.parentNode);'
882884
} ]
883885
}, {
884-
content: 'Delete Room',
886+
content: idrinth.text.get ( "chat.ui.deleteRoom" ),
885887
type: 'li',
886888
attributes: [ {
887889
name: 'onclick',
888890
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);'
889891
} ]
890892
}, {
891893
type: 'li',
892-
content: 'Close',
894+
content: idrinth.text.get ( "chat.ui.close" ),
893895
attributes: [ {
894896
name: 'onclick',
895897
value: 'this.parentNode.parentNode.removeChild(this.parentNode);'
@@ -930,20 +932,6 @@ idrinth.chat = {
930932
element.innerHTML = '>>';
931933
}
932934
},
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-
},
947935
loginActions: function ( key ) {
948936
var chatLogin,
949937
success,
@@ -953,7 +941,7 @@ idrinth.chat = {
953941
'relogin': 'chat-service/login/'
954942
},
955943
fail = function () {
956-
idrinth.core.alert ( this.getMsg ( 'login.fail' ) );
944+
idrinth.core.alert ( idrinth.text.get ( "chat.error.login" ) );
957945
},
958946
timeout = function () {
959947
window.setTimeout ( idrinth.chat.login, 1 );

Diff for: src/mods/land.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ idrinth.land = {
7070
}
7171
var results = baseCalculator ( getRequirements () );
7272
if ( Object.keys ( results ).length === 0 ) {
73-
idrinth.core.alert ( 'You lack gold to buy any more buildings at the moment.' );
73+
idrinth.core.alert ( idrinth.text.get ( "land.lackgold" ) );
7474
}
7575
putResults ( results );
7676
},

0 commit comments

Comments
 (0)