<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: GetText::Rails</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">GetText::Rails</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/gettext/rails_rb.html">
                lib/gettext/rails.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
<a href="Rails.html">GetText::Rails</a> supports Ruby on Rails. You add
only 2 lines in your controller, all of the controller/view/models are
targeted the textdomain.
</p>
<p>
See &lt;Ruby-<a href="../GetText.html">GetText</a>-Package HOWTO for Ruby
on Rails (<a
href="http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html">www.yotabanana.com/hiki/ruby-gettext-howto-rails.html</a>&gt;.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000059">available_locales</a>&nbsp;&nbsp;
      <a href="#M000058">bindtextdomain</a>&nbsp;&nbsp;
      <a href="#M000060">normalized_locale</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="../GetText.html">GetText</a></span>
      </div>
    </div>

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">Rails</td>
          <td>=</td>
          <td class="context-item-value">::Rails  #:nodoc:</td>
        </tr>
        </table>
      </div>
    </div>

    <div id="aliases-list">
      <h3 class="section-bar">External Aliases</h3>

      <div class="name-list">
                        <table summary="aliases">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">bindtextdomain</td>
          <td>-&gt;</td>
          <td class="context-item-value">_bindtextdomain</td>
        </tr>
                        </table>
      </div>
    </div>


      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000059" class="method-detail">
        <a name="M000059"></a>

        <div class="method-heading">
          <a href="#M000059" class="method-signature">
          <span class="method-name">available_locales</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns locales which supported by the application. This function returns
an reversed array of the locale strings under RAILS_ROOT/locale/*. It is
used for restriction such as caching files.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000059-source">
<pre>
    <span class="ruby-comment cmt"># File lib/gettext/rails.rb, line 67</span>
67:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">available_locales</span>
68:       <span class="ruby-keyword kw">unless</span> (<span class="ruby-constant">GetText</span>.<span class="ruby-identifier">cached?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@@available_locales</span>)
69:         <span class="ruby-ivar">@@available_locales</span> = (<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">RAILS_ROOT</span>, <span class="ruby-value str">&quot;locale/[a-z]*&quot;</span>)).<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">path</span>)} <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;en&quot;</span>).<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">reverse</span>
70:       <span class="ruby-keyword kw">end</span>
71:       <span class="ruby-ivar">@@available_locales</span>
72:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000058" class="method-detail">
        <a name="M000058"></a>

        <div class="method-heading">
          <a href="#M000058" class="method-signature">
          <span class="method-name">bindtextdomain(domainname, options = {})<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Bind a textdomain(#{path}/#{locale}/LC_MESSAGES/#{domainname}.mo) to your
program. Notes the textdomain scope becomes all of the
controllers/views/models in your app. This is different from normal
GetText.bindtextomain.
</p>
<p>
Usually, you don&#8216;t call this directly in your rails application. Call
init_gettext in ActionController::Base instead.
</p>
<p>
On the other hand, you need to call this in helpers/plugins.
</p>
<ul>
<li>domainname: the textdomain name.

</li>
<li>options: options as a Hash.

<ul>
<li>:locale - the locale value such as &quot;ja-JP&quot;. When the value is
nil, locale is searched the order by this value &gt; &quot;lang&quot; value
of QUERY_STRING &gt; params[&quot;lang&quot;] &gt; &quot;lang&quot; value
of Cookie &gt; HTTP_ACCEPT_LANGUAGE value &gt; Default locale(en).

</li>
<li>:path - the path to the mo-files. Default is &quot;RAIL_ROOT/locale&quot;.

</li>
<li>:charset - the charset. Generally UTF-8 is recommanded. And the charset is
set order by &quot;the argument of <a
href="Rails.html#M000058">bindtextdomain</a>&quot; &gt; HTTP_ACCEPT_CHARSET
&gt; Default charset(UTF-8).

</li>
</ul>
</li>
</ul>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000058-source">
<pre>
    <span class="ruby-comment cmt"># File lib/gettext/rails.rb, line 58</span>
58:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bindtextdomain</span>(<span class="ruby-identifier">domainname</span>, <span class="ruby-identifier">options</span> = {})
59:       <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">RAILS_ROOT</span>, <span class="ruby-value str">&quot;locale&quot;</span>)
60:       <span class="ruby-identifier">_bindtextdomain</span>(<span class="ruby-identifier">domainname</span>, <span class="ruby-identifier">options</span>)
61:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000060" class="method-detail">
        <a name="M000060"></a>

        <div class="method-heading">
          <a href="#M000060" class="method-signature">
          <span class="method-name">normalized_locale</span><span class="method-args">(locale = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a normalized locale which is in <a
href="Rails.html#M000059">available_locales</a>.
</p>
<ul>
<li>locale: a <a href="../Locale/Object.html">Locale::Object</a> or nil.

</li>
</ul>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000060-source">
<pre>
    <span class="ruby-comment cmt"># File lib/gettext/rails.rb, line 76</span>
76:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalized_locale</span>(<span class="ruby-identifier">locale</span> = <span class="ruby-keyword kw">nil</span>)
77:       <span class="ruby-identifier">locale</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">GetText</span>.<span class="ruby-identifier">locale</span>
78:       (<span class="ruby-identifier">available_locales</span> <span class="ruby-operator">&amp;</span>
79:         [<span class="ruby-identifier">locale</span>.<span class="ruby-identifier">to_general</span>, <span class="ruby-identifier">locale</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">locale</span>.<span class="ruby-identifier">language</span>, <span class="ruby-constant">Locale</span>.<span class="ruby-identifier">default</span>.<span class="ruby-identifier">language</span>, <span class="ruby-value str">&quot;en&quot;</span>].<span class="ruby-identifier">uniq</span>)[<span class="ruby-value">0</span>]
80:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>