Changeset 134

Show
Ignore:
Timestamp:
03/03/06 13:20:34 (6 years ago)
Author:
mj
Message:

Use a i18n method to replace text

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wikipedia/godmode-light/trunk/godmode-light.js

    r133 r134  
    179179  } 
    180180  return str; 
     181} 
     182 
     183// Helper function for i18n text 
     184var _placeholder = /\$(\d+)/; 
     185function _(text) { 
     186  // Additional arguments are used to replace $N placeholders in the text, 
     187  // starting at $1. 
     188  while (_placeholder.test(text)) { 
     189    var index = _placeholder.exec(text)[1]; 
     190    var replacement = '[no replacement text found]'; 
     191    if (index > 0 && index < arguments.length) 
     192      replacement = arguments[index]; 
     193    text = text.replace(_placeholder, replacement); 
     194  } 
     195  return text; 
    181196} 
    182197 
     
    288303  for (i = l.length; i--; ) { 
    289304    if (l[i].name == 'wpSummary') { 
    290       l[i].value = revertpage.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal); 
     305      l[i].value = _(revertpage, gml_editor, gml_vandal); 
    291306    } else if (l[i].name == 'wpMinoredit') { 
    292307      l[i].value = '1';