Jump to content

What is this .. __("something") ?


thepurpleblob
 Share

Recommended Posts

Ok... get the idea. Thanks.

I'm going to add this to the list of things that I would give one of my devs a row about, though ?   Along with jQuery's '$', most uses of try..catch (rather than writing proper error handling) and anything that results in 'unknown error'. Always use descriptive function names. I don't mind typing a few extra letters.

Link to comment
Share on other sites

It is quite common to use one or two characters for "translate functions", since they are typed and used a lot. Some examples:

Underscore appears to be a popular one.

 

  • Like 5
Link to comment
Share on other sites

11 hours ago, szabesz said:

It is quite common to use one or two characters for "translate functions", since they are typed and used a lot. Some examples:

Underscore appears to be a popular one.

 

Yeh - so I see. Now I've dug a bit more. I'd not encountered it before. 

I'm still horrified but as I'm not going to write my own CMS I'll just shut up now ?

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Old discussion, but yeah – the plus sides of this kind of naming are that 1) it's a common practice across different systems (which makes it easy for new devs to grasp), and 2) that it's a very commonly typed function – not to mention one that you often see in front-end (or "view") part of a site or an app, and thus it's good to keep it nice and short .

Expanding on the second point a bit, in the view side it often makes sense to have short function names, even if they're not particularly descriptive. Think of PHP's short echo tags (<?= ... ?>) or various tags implemented by templating languages: the point is to create minimal clutter, thus keeping view files clean and easy to follow ?

---

Note: this thread is not related to module development per se, so I'm moving it to the Getting Started area of the forum.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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