I am working on the L10n part of my website's backend. I have a static class that reads language files and another class to print strings from the chosen language.
So I only see "echo L::S('Welcome', 'AlicanC')" when coding for the front end. First "Welcome" get replaced with the matching string from the language file ("Welcome %1$s to %2$s") and then its moved to vsprintf() with other passed parameters.
I aimed for a system that would let me code easily and be failsafe. (Or fault-forgiving atleast...)
I "really" hate doing this, but after some thinking I came up with this solution:
//Push a string for each '%' mark in the string for avoiding "Too few arguments" error.
for($i= 0; strpos($String, '%', $i)!==false; $i= strpos($String, '%', $i)+1)
array_push($Arguments, '%NULL%');
In other scripting languages I used, missing arguments are just ignored and left unmodified. I don't understand why PHP complains about missing arguments.