Jump to content

Coding convention


Guest ErwinB

Recommended Posts

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

We ported over to the

'key' => val

format for 2.2, instead of the mixture of

'key' => val
$lang['key'] = val;

that was in place before

The use of sinqle quotes vs double quotes is a very fine line. You only need double quotes if

1) 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 apostrophe

Javascript 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 strings

2) 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

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...