ErwinB Posted February 20, 2007 Share Posted February 20, 2007 I'm posting this because after reading and reading again language files, I'm a bit tired. No convention is done between standard string or JavaScript string (or partially).One more thing, we should have this 'key' => "value"but sometimes we have 'key' => 'value'What's the right syntax? To translate language files, it's really difficult, as it seems to be no coding conventions.I think each language string should be:'key' => "value"and'js_key' => "value"for each entry used into JavaScript.It's already the case for some parts, but not always...So I think we should have a coding standard to make easier making language pack for IP products, without having to test every bit of JS code. Link to comment Share on other sites More sharing options...
bfarber Posted February 20, 2007 Share Posted February 20, 2007 We ported over to the 'key' => valformat for 2.2, instead of the mixture of'key' => val$lang['key'] = val;that was in place beforeThe use of sinqle quotes vs double quotes is a very fine line. You only need double quotes if1) There is a variable to be parsed (not common for lang strings)2) There is a new line/tab to be parsed (again, not very common)We sometimes use double quotes if the language bit has an apostrophe in it, as it's easier to read without having to escape the apostropheJavascript lang files simply don't have the exact same syntax, so I'm afraid there's not much room for changes there. ;)To summarize:1) It generally doesn't matter if you use single quotes or double quotes, but if in doubt use double quotes. The only advantage to single quotes is the php parser doesn't look for variables and try to replace them - in theory this is faster and preferred if there aren't actually variables in the lang strings2) The convention is about as set as it can get. I try to use single quotes when possible, just because the less processing the faster the script runs. I use double quotes when it's necessary, or when it will make the string easier to understand. Link to comment Share on other sites More sharing options...
Sam A Posted February 21, 2007 Share Posted February 21, 2007 We sometimes use double quotes if the language bit has an apostrophe in it, as it's easier to read without having to escape the apostropheShouldn't the apostrophe be an entity anyway? :P Link to comment Share on other sites More sharing options...
bfarber Posted February 22, 2007 Share Posted February 22, 2007 It doesn't really matter much in a language string. :) It's valid html with apostrophe's directly in the source and lang strings aren't imported into the db at any point. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.