-
Notifications
You must be signed in to change notification settings - Fork 84
Refactor: Translations #2440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Refactor: Translations #2440
Changes from all commits
029e478
a3c9185
4312b66
5d3b4ec
19b3b24
4bdcdc9
923137c
1b12c39
0a89e9d
b7dd858
36fab68
19051d6
8f7eccb
eb5aa36
747c98b
6574f15
fa6ec4b
26a56a4
5ee0a4c
3da4dc9
21df9f8
9ca6d53
041cf87
576e1db
7b78608
81142f5
970b60d
c1b91cd
4cda58c
b3af9b5
8f6f8d4
6356be1
f495c80
69bc3fc
27f2fec
8d08075
c52f0aa
05f145c
5fbb1f3
5ed0d36
e9d83fa
15b430d
7581e8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -64,20 +64,20 @@ function removeUserTemplate(template) { | |||||
| } | ||||||
|
|
||||||
| function confirmRemoveUserTemplate(template) { | ||||||
| swal({title:"_(Proceed)_?",text:"Remove user template: " + template ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(p){if (p) removeUserTemplate(template); else refresh();}); | ||||||
| swal({title:"_(Proceed?)_",text:"Remove user template: " + template ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(p){if (p) removeUserTemplate(template); else refresh();}); | ||||||
| } | ||||||
|
|
||||||
| function saveUserTemplateFile(name,template) { | ||||||
| $.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-save',name:name,template:template,replace:"no"},function($return){ | ||||||
| if ($return.success == false) { | ||||||
| swal({title:"_(File exists)_?",text:"Replace file: " + name ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(No)_"},function(p){ | ||||||
| swal({title:"_(File exists)_",text:"Replace file: " + name ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(No)_"},function(p){ | ||||||
| if (p) { | ||||||
| $.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-save',name:name,template:template,replace:"yes"},function($return){ | ||||||
| if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| if ($return.success == false) swal({title:"_(Error occurred)_",text:"Action error " + name + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| }); | ||||||
| } | ||||||
| else { | ||||||
| if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name + " " + $return.error ,type:'error',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| if ($return.success == false) swal({title:"_(Error occurred)_",text:"Action error " + name + " " + $return.error ,type:'error',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| }; | ||||||
| }); | ||||||
| } | ||||||
|
|
@@ -87,15 +87,15 @@ function saveUserTemplateFile(name,template) { | |||||
| function saveUserTemplateImport(name,template) { | ||||||
| $.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-import',name:name,template:template,replace:"no"},function($return){ | ||||||
| if ($return.success == false) { | ||||||
| swal({title:"_(File exists)_?",text:"Replace file: " + name.split(".")[0] ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(No)_"},function(p){ | ||||||
| swal({title:"_(File exists)_",text:"Replace file: " + name.split(".")[0] ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(No)_"},function(p){ | ||||||
| if (p) { | ||||||
| $.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-save',name:name,template:template,replace:"yes"},function($return){ | ||||||
| if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name.split(".")[0] + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| if ($return.success == false) swal({title:"_(Error occurred)_?",text:"Action error " + name.split(".")[0] + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix inconsistent punctuation in error dialog title. This line still has an external question mark after the translation wrapper, while all other "Error occurred" instances (lines 76, 80, 98) have been updated to remove it. This inconsistency should be corrected for uniform localization. Apply this diff to fix the inconsistency: - if ($return.success == false) swal({title:"_(Error occurred)_?",text:"Action error " + name.split(".")[0] + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"});
+ if ($return.success == false) swal({title:"_(Error occurred)_",text:"Action error " + name.split(".")[0] + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| if ($return.success == true) refresh(); | ||||||
| }); | ||||||
| } | ||||||
| else { | ||||||
| if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name + " " + $return.error ,type:'error',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| if ($return.success == false) swal({title:"_(Error occurred)_",text:"Action error " + name + " " + $return.error ,type:'error',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"}); | ||||||
| }; | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -86,11 +86,12 @@ function missing_cache() { | |||||
| } | ||||||
|
|
||||||
| function resync($d) { | ||||||
| return in_array($d,['P','Q']) ? 'Parity-Sync' : 'Data-Rebuild'; | ||||||
| return in_array($d,['P','Q']) ? _('Parity-Sync') : _('Data-Rebuild'); | ||||||
| } | ||||||
|
|
||||||
| function print_error($error) { | ||||||
| return sprintf(_('Finding **%s** error'.($error==1?'':'s')),$error?:'0'); | ||||||
| $n = (int)($error ?: 0); | ||||||
| return sprintf(ngettext('Finding **%d** error','Finding **%d** errors',$n),$n); | ||||||
| } | ||||||
| ?> | ||||||
| <script> | ||||||
|
|
@@ -290,7 +291,7 @@ function stopArray(form) { | |||||
| $(form).append('<input type="hidden" name="cmdStop" value="Stop">'); | ||||||
| <?if ($confirm['stop']):?> | ||||||
| swal({ | ||||||
| title:"_(Proceed)_?", | ||||||
| title:"_(Proceed?)_", | ||||||
| text:"_(This will stop the array)_", | ||||||
| type:'warning', | ||||||
| html:true, | ||||||
|
|
@@ -309,7 +310,7 @@ function stopParity(form, text) { | |||||
| $(form).append('<input type="hidden" name="cmdCheckCancel" value="">'); | ||||||
| <?if ($confirm['stop']):?> | ||||||
| swal({ | ||||||
| title:"_(Proceed)_?", | ||||||
| title:"_(Proceed?)_", | ||||||
| text:"_(This will stop the running operation)_: "+text, | ||||||
| type:'warning', | ||||||
| html:true, | ||||||
|
|
@@ -384,7 +385,7 @@ function shutdown_now(form, cmd) { | |||||
| break; | ||||||
| } | ||||||
| swal({ | ||||||
| title:"_(Proceed)_?", | ||||||
| title:"_(Proceed?)_", | ||||||
| text:text, | ||||||
| type:'warning', | ||||||
| html:true, | ||||||
|
|
@@ -600,7 +601,7 @@ window.onunload = function(){ | |||||
| if (!$spot): | ||||||
| if ($action[0] == "recon"): | ||||||
| $resync = resync($action[1]); | ||||||
| ?> <tr><td></td><td><input type="submit" name="cmdCheckSync" value="_(Sync)_"></td><td>**<?=_('Sync')?>** <?=_("will start **$resync**")?>.</td></tr> | ||||||
| ?> <tr><td></td><td><input type="submit" name="cmdCheckSync" value="_(Sync)_"></td><td>**<?=_('Sync')?>** <?=sprintf(_("will start **%s**"),$resync)?>.</td></tr> | ||||||
| <? elseif ($action[0]=="clear"):?> | ||||||
| <tr><td></td><td><input type="submit" name="cmdCheckClear" value="_(Clear)_"></td><td>**_(Clear)_** _(will start **Disk-Clear** of new data disk(s))_.</td></tr> | ||||||
| <? else: | ||||||
|
|
@@ -647,12 +648,12 @@ window.onunload = function(){ | |||||
| else: | ||||||
| if ($action[0] == "recon"): | ||||||
| $resync = resync($action[1]); | ||||||
| ?> <tr><td><?=_("$resync in progress")?>.</td><td> | ||||||
| ?> <tr><td><?=sprintf(_("%s in progress"),$resync)?>.</td><td> | ||||||
| <span class="buttons-spaced"> | ||||||
| <input type="button" id="pauseButton"<?if (_var($var,'mdResync')):?> value="_(Pause)_" onclick="pauseParity(this.form)"<?else:?> value="_(Resume)_" onclick="resumeParity(this.form)"<?endif;?> disabled> | ||||||
| <input type="button" id="cancelButton" value="_(Cancel)_" onclick="stopParity(this.form,'<?=$resync?>')" disabled> | ||||||
| </span></td> | ||||||
| <td id="cancelText"><?if (_var($var,'mdResync')):?>**<?=_('Pause')?>** <?=_("will pause $resync")?>.<?else:?>**<?=_('Resume')?>** <?=_("will resume $resync")?>.<?endif;?><br>**<?=_('Cancel')?>** <?=_("will stop $resync")?>. | ||||||
| <td id="cancelText"><?if (_var($var,'mdResync')):?>**<?=_('Pause')?>** <?=sprintf(_("will pause %s"),$resync)?>.<?else:?>**<?=_('Resume')?>** <?=sprintf(_("will resume %s"),$resync)?>.<?endif;?><br>**<?=_('Cancel')?>** <?=sprintf(_("will stop %s"),$resync)?>. | ||||||
| <br>_(WARNING: canceling may leave the array unprotected)_!</td></tr> | ||||||
| <? elseif ($action[0] == "clear"):?> | ||||||
| <tr><td>_(Disk-Clear in progress)_.</td><td> | ||||||
|
|
@@ -681,7 +682,7 @@ window.onunload = function(){ | |||||
| $sbSynced = array_shift($synced) ?: _var($var,'sbSynced'); | ||||||
| $sbUpdate = _var($var,'mdResyncDt') ? $sbSynced : _var($var,'sbUpdated');?> | ||||||
| <tr><td></td><td><input type="button" value="_(History)_" onclick="parityHistory()"></td> | ||||||
| <td><?=sprintf(_('Current operation %s on **%s**'),(_var($var,'mdResyncDt')?_('started'):_('paused')),_(my_time($sbUpdate).day_count($sbUpdate),0))?></td></tr> | ||||||
| <td><?=(_('Current operation %1$s on **%2$s**'),(_var($var,'mdResyncDt')?_('started'):_('paused')),_(my_time($sbUpdate).day_count($sbUpdate),0))?></td></tr> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing sprintf call causes placeholder substitution failure. Line 685 is missing the Apply this diff to fix the issue: - <td><?=(_('Current operation %1$s on **%2$s**'),(_var($var,'mdResyncDt')?_('started'):_('paused')),_(my_time($sbUpdate).day_count($sbUpdate),0))?></td></tr>
+ <td><?=sprintf(_('Current operation %1$s on **%2$s**'),(_var($var,'mdResyncDt')?_('started'):_('paused')),_(my_time($sbUpdate).day_count($sbUpdate),0))?></td></tr>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| <tr><td>_(Total size)_:</td><td id="line0"></td><td></td></tr> | ||||||
| <tr><td>_(Elapsed time)_:</td><td id="line1"></td><td></td></tr> | ||||||
| <tr><td>_(Current position)_:</td><td id="line2"></td><td></td></tr> | ||||||
|
|
@@ -707,12 +708,12 @@ window.onunload = function(){ | |||||
| case "Copying":?> | ||||||
| <tr><td><?status_indicator()?>**_(Starting, copying)_... <span id="fsState"></span>**</td><td><input type="submit" name="cmdNoCopy" value="_(Cancel)_"></td><td></td></tr> | ||||||
| <tr><td></td><td><input type="button" value="_(History)_" onclick="parityHistory()"></td> | ||||||
| <td><?=sprintf(_('Current operation %s on **%s**'),_('started'),_(my_time(_var($var,'sbUpdated',0)).day_count(_var($var,'sbSynced',0)),0))?></td></tr> | ||||||
| <td><?=sprintf(_('Current operation started on **%s**'),_(my_time(_var($var,'sbUpdated',0)).day_count(_var($var,'sbUpdated',0)),0))?></td></tr> | ||||||
| <? break; | ||||||
| case "Clearing":?> | ||||||
| <tr><td><?status_indicator()?>**_(Started, clearing)_... <span id="fsState"></span>**</td><td><input type="submit" name="cmdNoClear" value="_(Cancel)_"></td><td></td></tr> | ||||||
| <tr><td></td><td><input type="button" value="_(History)_" onclick="parityHistory()"></td> | ||||||
| <td><?=sprintf(_('Current operation %s on **%s**'),_('started'),_(my_time(_var($var,'sbUpdated',0)).day_count(_var($var,'sbSynced',0)),0))?></td></tr> | ||||||
| <td><?=sprintf(_('Current operation started on **%s**'),_(my_time(_var($var,'sbUpdated',0)).day_count(_var($var,'sbUpdated',0)),0))?></td></tr> | ||||||
| <? break; | ||||||
| case "Stopping":?> | ||||||
| <tr><td><?status_indicator()?>**_(Stopping)_...**</td><td><input type="submit" name="cmdStop" value="_(Stop)_" disabled></td><td></td></tr> | ||||||
|
|
@@ -746,7 +747,7 @@ window.onunload = function(){ | |||||
| if ($action[0] == "recon"): | ||||||
| $resync = resync($action[1]); | ||||||
| ?> <tr><td><?status_indicator()?>**_(Stopped)_**. _(Configuration valid)_.</td><td><input type="button" id="cmdStart" value="_(Start)_" onclick="prepareInput(this.form,this)"></td> | ||||||
| <td>**<?=_('Start')?>** <?=_("will bring the array on-line and start **$resync**")?>.</td></tr> | ||||||
| <td>**<?=_('Start')?>** <?=sprintf(_("will bring the array on-line and start **%s**"),$resync)?>.</td></tr> | ||||||
| <? elseif ($action[0] == "clear"):?> | ||||||
| <tr><td><?status_indicator()?>**_(Stopped)_**. _(New data disk(s) detected)_.</td><td><input type="button" id="cmdStart" value="_(Start)_" onclick="prepareInput(this.form,this)"></td> | ||||||
| <td>**_(Start)_** _(will bring the array on-line and start **Disk-Clear** of new data disk(s))_.</td></tr> | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Escape template name before injecting into SweetAlert HTML.
This swal uses html:true and concatenates the unescaped
nameintotext. Iftmpl/nameever contains</&etc., this can render as HTML. Encode it first.Apply this diff:
function rmTemplate(tmpl) { var name = tmpl.split(/[\/]+/).pop(); - swal({title:"_(Are you sure?)_",text:"_(Remove template)_: "+name,type:"warning",html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){$("#rmTemplate").val(tmpl);$("#formTemplate1").submit();}); + var safeName = $('<div/>').text(name).html(); // encode for HTML + swal({title:"_(Are you sure?)_",text:"_(Remove template)_: "+safeName,type:"warning",html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){$("#rmTemplate").val(tmpl);$("#formTemplate1").submit();});Optionally, drop
html:truehere if no formatting is needed.Scan for other swal calls with
html:trueconcatenating variables:🏁 Script executed:
Length of output: 4008
🏁 Script executed:
Length of output: 78
🏁 Script executed:
Length of output: 62
🏁 Script executed:
Length of output: 318
🏁 Script executed:
Length of output: 0
Escape template name before injecting into SweetAlert HTML in both locations.
The
rmTemplatefunction concatenates an unescapednamevariable into the swaltextfield whilehtml:trueis enabled. This creates an XSS vulnerability iftmpl/namecontains HTML characters like<or&.Apply this fix to both:
function rmTemplate(tmpl) { var name = tmpl.split(/[\/]+/).pop(); - swal({title:"_(Are you sure?)_",text:"_(Remove template)_: "+name,type:"warning",html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){$("#rmTemplate").val(tmpl);$("#formTemplate1").submit();}); + var safeName = $('<div/>').text(name).html(); // encode for HTML + swal({title:"_(Are you sure?)_",text:"_(Remove template)_: "+safeName,type:"warning",html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){$("#rmTemplate").val(tmpl);$("#formTemplate1").submit();}); }function rmTemplate(tmpl) { var name = tmpl.split(/[\/]+/).pop(); - swal({title:"Are you sure?",text:"Remove template: "+name,type:"warning",html:true,showCancelButton:true},function(){$("#rmTemplate").val(tmpl);$("#formTemplate").submit();}); + var safeName = $('<div/>').text(name).html(); + swal({title:"Are you sure?",text:"Remove template: "+safeName,type:"warning",html:true,showCancelButton:true},function(){$("#rmTemplate").val(tmpl);$("#formTemplate").submit();}); }🤖 Prompt for AI Agents