Sha256: 55ef7612366bee73cbd30271680a3f89cb600e5dc2814a8c2dd2edc74c90066e

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

<!DOCTYPE html>
<html>
	<head>
		
			<title>Localization</title>
		
		<meta charset="UTF-8"/>
		
		<link rel="icon" type="image/png" href="../../_static/icon.png"/>
		<link rel="stylesheet" href="../../_static/site.css" type="text/css" media="screen"/>
		
		<script src="../../_components/jquery/jquery.min.js"></script>
		<script src="../../_components/jquery-syntax/jquery.syntax.min.js"></script>
		
		<script type="text/javascript">
		//<![CDATA[
			jQuery(function($) {
				$.syntax();
			});
		//]]>
		</script>
	</head>

	<body class="show">
		
	<nav> › <a href="../../index.html">Wiki</a> › <span>Middleware</span> › <a href="index.html">Localization</a></nav>

	
	<main>
		<h1 id="localization">Localization</h1>

<p>The localization middleware uses the <code>Accept-Language</code> header to guess the preferred locale out of the given options. If a request path maps to a resource, that resource is returned. Otherwise, a localized request is made.</p>

<pre><code class="language-ruby">use Utopia::Localization,
	:default_locale =&gt; 'en',
	:locales =&gt; ['en', 'de', 'ja', 'zh']
</code></pre>

<p>Somewhere further down the chain, you can localize a resource:</p>

<pre><code class="language-ruby">localization = Utopia::Localization[request]
show_welcome(localization.current_locale)
</code></pre>

	</main>
	
	<footer>
		Last Modified: 2020-04-28 11:35:36 +1200
		— middleware/localization/index.md
	</footer>

	</body>
</html>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
utopia-2.15.1 docs/middleware/localization/index.html
utopia-2.15.0 docs/middleware/localization/index.html
utopia-2.14.0 docs/middleware/localization/index.html