Fix i18n strings with format

Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
方而静 2023-10-07 08:23:22 +08:00
parent 66b93b81cd
commit 16dd19ab7f
Signed by: szTom
GPG Key ID: 072D999D60C6473C
7 changed files with 98 additions and 84 deletions

View File

@ -4,13 +4,13 @@ __config() -> {
'commands' -> { 'commands' -> {
'list' -> 'cmdList', 'list' -> 'cmdList',
'confirm' -> 'cmdStart', 'confirm' -> 'cmdStart',
'reset clear' -> 'cmdResetClear', 'reset' -> 'cmdResetClear'
'reset schedule' -> 'cmdReschedule'
}, },
}; };
import('ica-libs', 'shuffleList', 'countCareer', 'playerListNbt' import('ica-libs', 'shuffleList', 'countCareer', 'playerListNbt'
, 'findVoteMax', 'resetVotes'); , 'findVoteMax', 'resetVotes', 'getFirstUnsetGoal', 'useIcaInstead'
, 'startedReject');
import('ica-i18n', 'getLocaleKey'); import('ica-i18n', 'getLocaleKey');
__on_start() -> ( __on_start() -> (
@ -121,16 +121,6 @@ endFinish() -> (
endCleanup(); endCleanup();
); );
getFirstUnsetGoal() -> (
c_for(i = 0, i <= 5, i = i + 1, (
p = nbt_storage('ica:data'):str('Goals[{Slot: %db}]', i);
if(p == null, (
return(i);
))
));
return(6);
);
actionbarMessage(msg) -> ( actionbarMessage(msg) -> (
display_title(player('all'), 'actionbar', msg, 100, 100, 100); display_title(player('all'), 'actionbar', msg, 100, 100, 100);
); );
@ -201,9 +191,9 @@ startCollectStage() -> (
schedule(20, 'runUpdateCollect'); schedule(20, 'runUpdateCollect');
clearBossbars(); clearBossbars();
createBossbar('ica:time_counter', format(getLocaleKey('bossbar.time.title')) createBossbar('ica:time_counter', format('b ' + getLocaleKey('bossbar.time.title'))
, tm_total(), 'notched_6'); , tm_total(), 'notched_6');
createBossbar('ica:collected', format(getLocaleKey('bossbar.progress.title')) createBossbar('ica:collected', format('b ' + getLocaleKey('bossbar.progress.title'))
, 6, 'notched_6'); , 6, 'notched_6');
bossbar('ica:collected', 'value', 0); bossbar('ica:collected', 'value', 0);
@ -243,14 +233,6 @@ cmdResetClear() -> (
endCleanup(); endCleanup();
); );
cmdReschedule() -> (
if(!nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.pending')));
return(false)
));
schedule('runUpdateCollect', 20);
);
runUpdatePrepare() -> ( runUpdatePrepare() -> (
if(!nbt_storage('ica:data'):'Started', return()); if(!nbt_storage('ica:data'):'Started', return());
if(!nbt_storage('ica:data'):'Preparing', return()); if(!nbt_storage('ica:data'):'Preparing', return());
@ -271,7 +253,7 @@ cmdStart() -> (
)); ));
if(nbt_storage('ica:data'):'Started', ( if(nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.started'))); startedReject();
return(false) return(false)
)); ));
@ -290,7 +272,7 @@ cmdStart() -> (
put(nbt_storage('ica:data'):'Preparing', '1b'); put(nbt_storage('ica:data'):'Preparing', '1b');
put(nbt_storage('ica:data'):'Goals[].Completed', '0b'); put(nbt_storage('ica:data'):'Goals[].Completed', '0b');
createBossbar('ica:prepare_counter', format(getLocaleKey('bossbar.prepare.title')) createBossbar('ica:prepare_counter', format('b ' + getLocaleKey('bossbar.prepare.title'))
, tm_prepare(), null); , tm_prepare(), null);
schedule(20, 'runUpdatePrepare'); schedule(20, 'runUpdatePrepare');
@ -320,6 +302,6 @@ cmdStart() -> (
); );
cmdList() -> ( cmdList() -> (
print(format(getLocaleKey('instead'))); useIcaInstead();
run('/ica'); run('/ica');
); );

View File

@ -21,11 +21,11 @@ getStatus() -> (
updateEffects() -> ( updateEffects() -> (
if(global_enabled, ( if(global_enabled, (
for(player('all'), ( for(player('all'), (
modify(_, 'effect', 'regeneration', 600, 1, false, true); modify(_, 'effect', 'regeneration', 400, 1, false, true);
modify(_, 'effect', 'absorption', 600, 2, false, true); modify(_, 'effect', 'absorption', 400, 2, false, true);
)); ));
)); ));
schedule(400, 'updateEffects'); schedule(200, 'updateEffects');
); );
setBlock(pos, use_upper_half) -> ( setBlock(pos, use_upper_half) -> (

View File

@ -1,6 +1,6 @@
__config() -> { __config() -> {
'scope' -> 'global', 'scope' -> 'global',
'exports' -> ['getLocaleKey'], 'exports' -> ['getLocaleKey', 'useIcaInstead', 'startedReject', 'pendingReject'],
}; };
global_TranslateKeysEnUS = { global_TranslateKeysEnUS = {
@ -18,10 +18,10 @@ global_TranslateKeysEnUS = {
'submit.ddl.2' -> '[WARN] Submission deadline in %d seconds.', 'submit.ddl.2' -> '[WARN] Submission deadline in %d seconds.',
'submit.ddl.3' -> '[WARN] Submission deadline in %d second.', 'submit.ddl.3' -> '[WARN] Submission deadline in %d second.',
'submit.success' -> 'OK.', 'submit.success' -> 'OK.',
'submit.missing.before' -> ' Item ', 'submit.missing.before' -> 'Item ',
'submit.missing.after' -> ' not found.', 'submit.missing.after' -> ' not found.',
'submit.already.before' -> ' Item ', 'submit.already.before' -> 'Item ',
'submit.already.after' -> ' has already been collected.', 'submit.already.after' -> ' has already been collected.',
'election.kill' -> 'Election victim %s killed.', 'election.kill' -> 'Election victim %s killed.',
'election.ddl' -> '[WARN] Vote ends in 1 minute.', 'election.ddl' -> '[WARN] Vote ends in 1 minute.',
@ -30,18 +30,24 @@ global_TranslateKeysEnUS = {
'election.new' -> 'New election round started.', 'election.new' -> 'New election round started.',
'election.result' -> 'Election result: %s.', 'election.result' -> 'Election result: %s.',
'instead' -> 'd Please use /ica instead.', 'hint.instead.before' -> 'Please use ',
'hint.instead.after' -> ' instead.',
'hint.allset.before' -> 'All goals are set, you can use ',
'hint.allset.after' -> ' to start.',
'bossbar.prepare.title' -> 'b Preparing', 'goal.set.before' -> 'Goal #%d set to ',
'bossbar.time.title' -> 'b Time Left', 'goal.set.after' -> '.',
'bossbar.progress.title' -> 'b Collected',
'bossbar.prepare.title' -> 'Preparing',
'bossbar.time.title' -> 'Time Left',
'bossbar.progress.title' -> 'Collected',
'career.display.title' -> 'Career configs are:', 'career.display.title' -> 'Career configs are:',
'career.display.wolf' -> ' - Wolf: %d participants.', 'career.display.wolf' -> ' - Wolf: %d participants.',
'career.display.hunter' -> ' - Hunter(Fireball): %d participants.', 'career.display.hunter' -> ' - Hunter(Fireball): %d participants.',
'career.display.firework_hunter' -> ' - Hunter(Firework): %d participants.', 'career.display.firework_hunter' -> ' - Hunter(Firework): %d participants.',
'career.display.builder' -> ' - Builder: %d participants.', 'career.display.builder' -> ' - Builder: %d participants.',
'career.display.piggy' -> 'Career configs are:', 'career.display.piggy' -> '- Piggies: whatever the rest.',
'career.set' -> 'Career %s set to %d participants.', 'career.set' -> 'Career %s set to %d participants.',
'career.title.bystander' -> 'Bystander', 'career.title.bystander' -> 'Bystander',
@ -76,11 +82,14 @@ global_TranslateKeysEnUS = {
'ablity.format' -> '[ablity] %s: %s', 'ablity.format' -> '[ablity] %s: %s',
'reject.pending' -> [' Not started. use ', 'mb /ica-admin confirm', '?/ica-admin confirm', ' to start.'], 'reject.pending.before' -> 'Not started, use ',
'reject.started' -> [' Already started, use ', 'mb /ica-admin reset clear', '?/ica-admin reset clear', ' to cancel.'], 'reject.pending.after' -> ' to start.',
'reject.started.before' -> 'Already started, use ',
'reject.started.after' -> ' to cancel.',
'reject.leckplayer' -> ' Not enough players are online.', 'reject.leckplayer' -> ' Not enough players are online.',
'reject.goal.missing' -> 'Goal #%d is unset.', 'reject.goal.missing' -> 'Goal #%d is unset.',
'reject.goal.enough' -> [' All are goals set, please use ', 'mb /ica-settings set <slot> <item>', ' to replace.'], 'reject.goal.enough.before' -> 'All are goals set, please use ',
'reject.goal.enough.after' -> ' to replace.',
'reject.spyglass' -> 'Spyglass too hot, please wait another %.2f seconds to use again.', 'reject.spyglass' -> 'Spyglass too hot, please wait another %.2f seconds to use again.',
'reject.unable' -> 'You don\'t have this ability.', 'reject.unable' -> 'You don\'t have this ability.',
'reject.bystand' -> 'You can only bystand.', 'reject.bystand' -> 'You can only bystand.',
@ -117,9 +126,27 @@ global_TranslateKeysEnUS = {
'misc.clipboard' -> 'Click To Copy', 'misc.clipboard' -> 'Click To Copy',
'license.header' -> 'ICollect-Alpha, Copyright (C) 2023 方而静\nICollect-Alpha comes with ABSOLUTELY NO WARRANTY;\nfor details type \'/ica-loader show w\'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type \'/ica-loader show c\' for details.', 'license.header' -> 'ICollect-Alpha, Copyright (C) 2023 方而静\nICollect-Alpha comes with ABSOLUTELY NO WARRANTY;\nfor details type \'/ica-loader show w\'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type \'/ica-loader show c\' for details.'
}; };
getLocaleKey(keyid) -> ( getLocaleKey(keyid) -> (
if(has(global_TranslateKeysEnUS:keyid), global_TranslateKeysEnUS:keyid, 'tkey:' + keyid) if(has(global_TranslateKeysEnUS:keyid), global_TranslateKeysEnUS:keyid, 'tkey:' + keyid)
); );
useIcaInstead() -> (
print(format('d ' + getLocaleKey('hint.instead.before')
, 'mb /ica', '?/ica'
, 'd ' + getLocaleKey('hint.instead.after')));
);
startedReject() -> (
print(format(' ' + getLocaleKey('reject.started.before')
, 'mb /ica-admin reset', '?/ica-admin reset'
, ' ' + getLocaleKey('reject.started.after')));
);
pendingReject() -> (
print(format(' ' + getLocaleKey('reject.pending.before')
, 'mb /ica-admin confirm', '?/ica-admin confirm'
, ' ' + getLocaleKey('reject.pending.after')));
);

View File

@ -1,7 +1,8 @@
__config() -> { __config() -> {
'scope' -> 'global', 'scope' -> 'global',
'exports' -> ['shuffleList', 'countCareer', 'findVoteMax', 'resetVotes' 'exports' -> ['shuffleList', 'countCareer', 'findVoteMax', 'resetVotes'
, 'playerListNbt', 'listContain', 'countVotes', 'countAbstainVotes'], , 'playerListNbt', 'listContain', 'countVotes', 'countAbstainVotes'
, 'getFirstUnsetGoal'],
}; };
shuffleList(list) -> ( shuffleList(list) -> (
@ -75,3 +76,13 @@ findVoteMax() -> (
resetVotes() -> ( resetVotes() -> (
put(nbt_storage('ica:voting'), 'Votes', '[]'); put(nbt_storage('ica:voting'), 'Votes', '[]');
); );
getFirstUnsetGoal() -> (
c_for(i = 0, i <= 5, i = i + 1, (
p = nbt_storage('ica:data'):str('Goals[{Slot: %db}]', i);
if(p == null, (
return(i);
))
));
return(6);
);

View File

@ -18,27 +18,17 @@ __config() -> {
}, },
}; };
import('ica-i18n', 'getLocaleKey'); import('ica-i18n', 'getLocaleKey', 'useIcaInstead', 'startedReject', 'pendingReject');
import('ica-libs', 'countCareer'); import('ica-libs', 'countCareer', 'getFirstUnsetGoal');
getFirstUnsetGoal() -> (
c_for(i = 0, i <= 5, i = i + 1, (
p = nbt_storage('ica:data'):str('Goals[{Slot: %db}]', i);
if(p == null, (
return(i);
))
));
return(6);
);
cmdList() -> ( cmdList() -> (
print(format(getLocaleKey('instead'))); useIcaInstead();
run('/ica'); run('/ica');
); );
cmdSet(slot_id, goal_item_tuple) -> ( cmdSet(slot_id, goal_item_tuple) -> (
if(nbt_storage('ica:data'):'Started', ( if(nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.started'))); startedReject();
return(false) return(false)
)); ));
pkey = str('Goals[{Slot: %db}]', slot_id); pkey = str('Goals[{Slot: %db}]', slot_id);
@ -46,7 +36,14 @@ cmdSet(slot_id, goal_item_tuple) -> (
if(nbt_storage('ica:data'):pkey != null, delete(nbt_storage('ica:data'):pkey)); if(nbt_storage('ica:data'):pkey != null, delete(nbt_storage('ica:data'):pkey));
put(nbt_storage('ica:data'), 'Goals', etag, -1); put(nbt_storage('ica:data'), 'Goals', etag, -1);
print(str('Goal #%d set to %s.', slot_id, goal_item_tuple:0)) print(format(' ' + str(getLocaleKey('goal.set.before'), slot_id)
, 'b ' + item_display_name(goal_item_tuple:0), '^ minecraft:' + goal_item_tuple:0
, ' ' + getLocaleKey('goal.set.after'));
if(getFirstUnsetGoal() > 5, (
print(format(' ' + getLocaleKey('hint.allset.before')
, 'mb /ica-admin confirm', '?/ica-admin confirm'
, ' ' + getLocaleKey('hint.allset.after')));
));
); );
cmdSetAppend(goal_item_tuple) -> ( cmdSetAppend(goal_item_tuple) -> (
@ -54,7 +51,9 @@ cmdSetAppend(goal_item_tuple) -> (
if(missing_goal <= 5, ( if(missing_goal <= 5, (
cmdSet(missing_goal, goal_item_tuple) cmdSet(missing_goal, goal_item_tuple)
), ( ), (
print(format(getLocaleKey('reject.goal.enough'))) print(format(' ' + getLocaleKey('reject.goal.enough.before')
, 'mb /ica-settings set <slot> <item>', '?/ica-settings set '
, ' ' + getLocaleKey('reject.goal.enough.after')));
)); ));
); );
@ -68,7 +67,7 @@ cmdListCareers() -> (
cmdConfigCareer(cartype, ccount) -> ( cmdConfigCareer(cartype, ccount) -> (
if(nbt_storage('ica:data'):'Started', ( if(nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.started'))); startedReject();
return(false) return(false)
)); ));
pkey = str('Config[{Type: "%s"}].Count', cartype); pkey = str('Config[{Type: "%s"}].Count', cartype);

View File

@ -26,7 +26,7 @@ cmdInfo() -> (
)); ));
cand_names = parse_nbt(nbt_storage('ica:voting'):'Candidates'); cand_names = parse_nbt(nbt_storage('ica:voting'):'Candidates');
cand_n = length(cand_names); cand_n = length(cand_names);
print(str(getLocaleKey('vote.title', cand_n)); print(str(getLocaleKey('vote.title', cand_n)));
for(cand_names, ( for(cand_names, (
p = player(_); p = player(_);
v_cnt = countVotes(_); v_cnt = countVotes(_);

View File

@ -25,7 +25,7 @@ __config() -> {
}; };
import('ica-libs', 'listContain'); import('ica-libs', 'listContain');
import('ica-i18n', 'getLocaleKey'); import('ica-i18n', 'getLocaleKey', 'startedReject', 'pendingReject');
global_capMarkerMap = { global_capMarkerMap = {
'builder' -> 'ica.build_spyglasser', 'builder' -> 'ica.build_spyglasser',
@ -33,14 +33,6 @@ global_capMarkerMap = {
'firework' -> 'ica.firework_spyglasser', 'firework' -> 'ica.firework_spyglasser',
}; };
tm_total() -> (
72000
);
tm_per_goal() -> (
12000
);
lackOfAbilityReject() -> ( lackOfAbilityReject() -> (
print(getLocaleKey('reject.unable')); print(getLocaleKey('reject.unable'));
); );
@ -51,7 +43,7 @@ bystandReject() -> (
cmdLocate(pname) -> ( cmdLocate(pname) -> (
if(!nbt_storage('ica:data'):'Started', ( if(!nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.pending'))); pendingReject();
return(false) return(false)
)); ));
myself = player(); myself = player();
@ -101,7 +93,7 @@ cmdSeed() -> (
cmdRefill() -> ( cmdRefill() -> (
if(!nbt_storage('ica:data'):'Started', ( if(!nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.pending'))); pendingReject();
return(false) return(false)
)); ));
myself = player(); myself = player();
@ -162,7 +154,7 @@ cmdList() -> (
cmdMe() -> ( cmdMe() -> (
if(!nbt_storage('ica:data'):'Started', ( if(!nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.pending'))); pendingReject();
return(false) return(false)
)); ));
myself = player(); myself = player();
@ -193,7 +185,7 @@ disableAllSpyglassAbilities(me) -> (
cmdSpyglassSwitch(feature_id) -> ( cmdSpyglassSwitch(feature_id) -> (
if(!nbt_storage('ica:data'):'Started', ( if(!nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.pending'))); pendingReject();
return(false) return(false)
)); ));
me = player(); me = player();
@ -216,7 +208,7 @@ cmdSpyglassSwitch(feature_id) -> (
cmdSubmit(slot_id) -> ( cmdSubmit(slot_id) -> (
if(!nbt_storage('ica:data'):'Started', ( if(!nbt_storage('ica:data'):'Started', (
print(format(getLocaleKey('reject.pending'))); pendingReject();
return(false) return(false)
)); ));
if(nbt_storage('ica:data'):'Preparing', ( if(nbt_storage('ica:data'):'Preparing', (
@ -230,17 +222,20 @@ cmdSubmit(slot_id) -> (
)); ));
pkey = str('Goals[{Slot: %db}]', slot_id); pkey = str('Goals[{Slot: %db}]', slot_id);
g_item = nbt_storage('ica:data'):pkey:'Item';
if(nbt_storage('ica:data'):pkey:'Completed', ( if(nbt_storage('ica:data'):pkey:'Completed', (
print(format(getLocaleKey('submit.already.before')) print(format(' ' + getLocaleKey('submit.already.before')
+ item_display_name(nbt_storage('ica:data'):pkey:'Item') , 'b ' + item_display_name(g_item)
+ format(getLocaleKey('submit.already.after'))); , '^ minecraft:' + g_item
, ' ' + getLocaleKey('submit.already.after')));
return() return()
)); ));
if(inventory_remove(me, nbt_storage('ica:data'):pkey:'Item', 1) == 0, ( if(inventory_remove(me, g_item, 1) == 0, (
print(format(getLocaleKey('submit.missing.before')) print(format(' ' + getLocaleKey('submit.missing.before')
+ item_display_name(nbt_storage('ica:data'):pkey:'Item') , 'b ' + item_display_name(g_item)
+ format(getLocaleKey('submit.missing.after'))); , '^ mincraft:' + g_item
, ' ' + getLocaleKey('submit.missing.after')));
return() return()
)); ));
put(nbt_storage('ica:data'):(pkey+'.Completed'), '1b'); put(nbt_storage('ica:data'):(pkey+'.Completed'), '1b');