Redmine/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/InstanceMethods.html

364 lines
15 KiB
HTML
Raw Normal View History

<?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: GLoc::InstanceMethods</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">GLoc::InstanceMethods</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/gloc_rb.html">
lib/gloc.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
This module will be included in both instances and classes of <a
href="../GLoc.html">GLoc</a> includees. It is also included as class
methods in the <a href="../GLoc.html">GLoc</a> module itself.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000029">l</a>&nbsp;&nbsp;
<a href="#M000034">l_has_string?</a>&nbsp;&nbsp;
<a href="#M000030">ll</a>&nbsp;&nbsp;
<a href="#M000031">ltry</a>&nbsp;&nbsp;
<a href="#M000032">lwr</a>&nbsp;&nbsp;
<a href="#M000033">lwr_</a>&nbsp;&nbsp;
<a href="#M000035">set_language</a>&nbsp;&nbsp;
<a href="#M000036">set_language_if_valid</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="Helpers.html">Helpers</a></span>
</div>
</div>
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000029" class="method-detail">
<a name="M000029"></a>
<div class="method-heading">
<a href="#M000029" class="method-signature">
<span class="method-name">l</span><span class="method-args">(symbol, *arguments)</span>
</a>
</div>
<div class="method-description">
<p>
Returns a localized string.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000029-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 18</span>
18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">l</span>(<span class="ruby-identifier">symbol</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
19: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">GLoc</span>.<span class="ruby-identifier">_l</span>(<span class="ruby-identifier">symbol</span>,<span class="ruby-identifier">current_language</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
20: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000034" class="method-detail">
<a name="M000034"></a>
<div class="method-heading">
<a href="#M000034" class="method-signature">
<span class="method-name">l_has_string?</span><span class="method-args">(symbol)</span>
</a>
</div>
<div class="method-description">
<p>
Returns <tt>true</tt> if a localized string with the specified key exists.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000034-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 48</span>
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">l_has_string?</span>(<span class="ruby-identifier">symbol</span>)
49: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">GLoc</span>.<span class="ruby-identifier">_l_has_string?</span>(<span class="ruby-identifier">symbol</span>,<span class="ruby-identifier">current_language</span>)
50: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000030" class="method-detail">
<a name="M000030"></a>
<div class="method-heading">
<a href="#M000030" class="method-signature">
<span class="method-name">ll</span><span class="method-args">(lang, symbol, *arguments)</span>
</a>
</div>
<div class="method-description">
<p>
Returns a localized string in a specified language. This does not effect
<tt>current_language</tt>.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000030-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 24</span>
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ll</span>(<span class="ruby-identifier">lang</span>, <span class="ruby-identifier">symbol</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
25: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">GLoc</span>.<span class="ruby-identifier">_l</span>(<span class="ruby-identifier">symbol</span>,<span class="ruby-identifier">lang</span>.<span class="ruby-identifier">to_sym</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
26: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000031" class="method-detail">
<a name="M000031"></a>
<div class="method-heading">
<a href="#M000031" class="method-signature">
<span class="method-name">ltry</span><span class="method-args">(possible_key)</span>
</a>
</div>
<div class="method-description">
<p>
Returns a localized string if the argument is a Symbol, else just returns
the argument.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000031-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 29</span>
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ltry</span>(<span class="ruby-identifier">possible_key</span>)
30: <span class="ruby-identifier">possible_key</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">l</span>(<span class="ruby-identifier">possible_key</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">possible_key</span>
31: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000032" class="method-detail">
<a name="M000032"></a>
<div class="method-heading">
<a href="#M000032" class="method-signature">
<span class="method-name">lwr</span><span class="method-args">(symbol, *arguments)</span>
</a>
</div>
<div class="method-description">
<p>
Uses the default <a href="../GLoc.html">GLoc</a> rule to return a localized
string. See lwr_() for more info.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000032-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 35</span>
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">lwr</span>(<span class="ruby-identifier">symbol</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
36: <span class="ruby-identifier">lwr_</span>(<span class="ruby-identifier">:default</span>, <span class="ruby-identifier">symbol</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
37: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000033" class="method-detail">
<a name="M000033"></a>
<div class="method-heading">
<a href="#M000033" class="method-signature">
<span class="method-name">lwr_</span><span class="method-args">(rule, symbol, *arguments)</span>
</a>
</div>
<div class="method-description">
<p>
Uses a <em>rule</em> to return a localized string. A rule is a function
that uses specified arguments to return a localization key prefix. The
prefix is appended to the localization key originally specified, to create
a new key which is then used to lookup a localized string.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000033-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 43</span>
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">lwr_</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">symbol</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
44: <span class="ruby-constant">GLoc</span>.<span class="ruby-identifier">_l</span>(<span class="ruby-node">&quot;#{symbol}#{GLoc::_l_rule(rule,current_language).call(*arguments)}&quot;</span>,<span class="ruby-identifier">current_language</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
45: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000035" class="method-detail">
<a name="M000035"></a>
<div class="method-heading">
<a href="#M000035" class="method-signature">
<span class="method-name">set_language</span><span class="method-args">(language)</span>
</a>
</div>
<div class="method-description">
<p>
Sets the current language for this instance/class. Setting the language of
a class effects all instances unless the instance has its own language
defined.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000035-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 54</span>
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_language</span>(<span class="ruby-identifier">language</span>)
55: <span class="ruby-ivar">@gloc_language</span>= <span class="ruby-identifier">language</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">language</span>.<span class="ruby-identifier">to_sym</span>
56: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000036" class="method-detail">
<a name="M000036"></a>
<div class="method-heading">
<a href="#M000036" class="method-signature">
<span class="method-name">set_language_if_valid</span><span class="method-args">(language)</span>
</a>
</div>
<div class="method-description">
<p>
Sets the current language if the language passed is a valid language. If
the language was valid, this method returns <tt>true</tt> else it will
return <tt>false</tt>. Note that <tt>nil</tt> is not a valid language. See
<a href="InstanceMethods.html#M000035">set_language</a>(language) for more
info.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000036-source">
<pre>
<span class="ruby-comment cmt"># File lib/gloc.rb, line 62</span>
62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_language_if_valid</span>(<span class="ruby-identifier">language</span>)
63: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">GLoc</span>.<span class="ruby-identifier">valid_language?</span>(<span class="ruby-identifier">language</span>)
64: <span class="ruby-identifier">set_language</span>(<span class="ruby-identifier">language</span>)
65: <span class="ruby-keyword kw">true</span>
66: <span class="ruby-keyword kw">else</span>
67: <span class="ruby-keyword kw">false</span>
68: <span class="ruby-keyword kw">end</span>
69: <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>