Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a Ruby string wrapped in _() mean?

Tags:

ruby

I'm looking at a Sinatra app for a CAS server for SSO. I'm unsure what the underscore and parentheses mean in the string assignment. Here's a sample line:

@message = {:type => 'confirmation', :message => _("You have successfully logged in.")}

But it's also used in ERB:

<%= _("Username") %>
like image 957
mrturtle Avatar asked Jul 14 '26 07:07

mrturtle


1 Answers

_ is the name of the translation method of GetText.

So _ basically means: Take the following string and use it as a key to find a localized/translated version.

like image 54
spickermann Avatar answered Jul 21 '26 07:07

spickermann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!