Hey, I guess this is mainly aimed at the core team...
I'm working on a fairly high profile site for an international client. This is not the first site I've built requiring translation, but it's the first one that HAS to be perfect and needs full translation of both the site and the dashboard. Elements that aren't yet translated in the .po files are less of a concern - we have budget for translators. However, the one issue I've been consistently bumping into are strings that are stored in the db. I realize that they can be translated on the way into the db, so that the dashboard can run in a different language, but I need users to be able to select which language they wish to work in when they access the dashboard. And for this client, having attribute names not translated is not an option.
So I got looking at the problem. On the one hand, this isn't actually that big a deal for me. The t() function can handle variables just fine, as php will pass the string from the db to t() and so it will translate. So for one off installations, all that really needs to be done is for me to go through the core and wrap all the relevant variables with t() and they get translated.
As a full blown solution, however, I realize that this wont really cut it, as you need to scan the core for the t() function to extract the strings for translation and we don't want poedit getting littered with variables.
So my suggestion would be this. All variables get wrapped in tVar(). We then add a function to localization.php as follows:
function tVar($text){return t($text);}
This way, when you scan for strings, you wont fill poedit up with variable names, but as the attribute and block names etc. are all already wrapped in t() in their various controllers / install routines, they will get picked up and translated.
Would this work? Can anyone see any reason not to do this?
thanks for the response, but you've kinda missed the point here.
I'm not referring to strings that are not in the .po file but should be, I'm referring to strings that come out of the database and are displayed as variables in the source code. Quite often these strings are in the .po file and are already translated, but they can be displayed in the correct language, as the variables are not wrapped in t().
So, clear me up. What vars are you meaning. You do not need to use a wrapped t() for database generated content. The t() is only as a reverence for parsing and searching (php/html/js files). The hint i gave you translate the strings/vars pult from the database. So just try it first! It really works well. Attribute can be translated to!
Just get the exact name. And make some minor edits to your po file, parse it ready to go>
.Peter
Code
Post Reply
Delete Post
You are allowed to delete your post for 5 minutes after it's posted.