Concept and Example
Here is an example, using pseudo code.
Code: Select all
$message1 = sprintf: fmt='%s attacks %s', $attacker, [playership], null, null, null
$message2= null-> call script 'positional format' :fmt='{0} attacks {1}', obj0=$attacker, obj1=[playership], obj2=null, obj3=null, obj4=null
Now if we want to change the message to passive voice, we have to modify the code to the following.
Code: Select all
$message1 = sprintf: fmt='%s is attacked by %s', [playership], $attacker, null, null, null
$message2= null-> call script 'positional format' :fmt='{1} is attacked by {1}', obj0=$attacker, obj1=[playership], obj2=null, obj3=null, obj4=null
The arguments of 'positional format' are actually
•0: pageid , Number , 'pageid'
•1: textid , Number , 'textid'
•2: obj0 , Value , '{0}'
•3: obj1 , Value , '{1}'
•4: obj2 , Value , '{2}'
•5: obj3 , Value , '{3}'
•6: obj4 , Value , '{4}'
Making use of positional format will greatly contribute to the globlization and localization of scripts. You should use 'positional format' to read and format external text files.
Different locales have varied language habit. If English likes passive voice, Chinese like positive voice. If a translator translates a script written in English to Chinses and if the author uses 'positional format', the translator doesn't have to modify the source code of the script, or use non-native sentence to suit the order of arguments.
Download
version: 0 experimental, 2013-08-28
author: gqqnbig
Compatibility: compatible to X3R. Others are not tested.
Download (SPK):Box.com, Dropbox
Install:
Install X-Universe Plugin Manager Lite first,then double click positioal format-V0-28.8.2013.spk.
Uninstall or Disable:
Use X-Universe Plugin Manager Lite to uninstall or disable.
Feedbacks are welcomed, of both introduction of the package and technical issues. Feel free if you have any question and don't hesitate to tell me if there is a duplicate library.
I'm developing some scripts that use this libray and should release soon.
Technical supports end on Februaray 1st, 2014.