|
| 1 | +<?xml version="1.0" encoding="utf-8" ?> |
| 2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 4 | +<!-- This file is generated by Nim. --> |
| 5 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 6 | +<head> |
| 7 | +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 8 | + |
| 9 | +<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 10 | + |
| 11 | +<!-- Favicon --> |
| 12 | +<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/> |
| 13 | +<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII="> |
| 14 | + |
| 15 | +<!-- Google fonts --> |
| 16 | +<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/> |
| 17 | +<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/> |
| 18 | + |
| 19 | +<!-- CSS --> |
| 20 | +<title>locale</title> |
| 21 | +<link rel="stylesheet" type="text/css" href="nimdoc.out.css"> |
| 22 | + |
| 23 | +<script type="text/javascript" src="dochack.js"></script> |
| 24 | + |
| 25 | +<script type="text/javascript"> |
| 26 | +function main() { |
| 27 | + var pragmaDots = document.getElementsByClassName("pragmadots"); |
| 28 | + for (var i = 0; i < pragmaDots.length; i++) { |
| 29 | + pragmaDots[i].onclick = function(event) { |
| 30 | + // Hide tease |
| 31 | + event.target.parentNode.style.display = "none"; |
| 32 | + // Show actual |
| 33 | + event.target.parentNode.nextElementSibling.style.display = "inline"; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]'); |
| 38 | + function switchTheme(e) { |
| 39 | + if (e.target.checked) { |
| 40 | + document.documentElement.setAttribute('data-theme', 'dark'); |
| 41 | + localStorage.setItem('theme', 'dark'); |
| 42 | + } else { |
| 43 | + document.documentElement.setAttribute('data-theme', 'light'); |
| 44 | + localStorage.setItem('theme', 'light'); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + toggleSwitch.addEventListener('change', switchTheme, false); |
| 49 | + |
| 50 | + const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null; |
| 51 | + if (currentTheme) { |
| 52 | + document.documentElement.setAttribute('data-theme', currentTheme); |
| 53 | + |
| 54 | + if (currentTheme === 'dark') { |
| 55 | + toggleSwitch.checked = true; |
| 56 | + } |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +window.addEventListener('DOMContentLoaded', main); |
| 61 | +</script> |
| 62 | + |
| 63 | +</head> |
| 64 | +<body> |
| 65 | +<div class="document" id="documentId"> |
| 66 | + <div class="container"> |
| 67 | + <h1 class="title">locale</h1> |
| 68 | + <div class="row"> |
| 69 | + <div class="three columns"> |
| 70 | + <div class="theme-switch-wrapper"> |
| 71 | + <label class="theme-switch" for="checkbox"> |
| 72 | + <input type="checkbox" id="checkbox" /> |
| 73 | + <div class="slider round"></div> |
| 74 | + </label> |
| 75 | + <em>Dark Mode</em> |
| 76 | + </div> |
| 77 | + <div id="global-links"> |
| 78 | + <ul class="simple"> |
| 79 | + <li> |
| 80 | + <a href="../index.html">Index</a> |
| 81 | + </li> |
| 82 | + </ul> |
| 83 | + </div> |
| 84 | + <div id="searchInputDiv"> |
| 85 | + Search: <input type="text" id="searchInput" |
| 86 | + onkeyup="search()" /> |
| 87 | + </div> |
| 88 | + <div> |
| 89 | + Group by: |
| 90 | + <select onchange="groupBy(this.value)"> |
| 91 | + <option value="section">Section</option> |
| 92 | + <option value="type">Type</option> |
| 93 | + </select> |
| 94 | + </div> |
| 95 | + <ul class="simple simple-toc" id="toc-list"> |
| 96 | +<li><a class="reference" id="localedotnim_toc" href="#localedotnim">locale.nim</a></li> |
| 97 | +<li> |
| 98 | + <a class="reference reference-toplevel" href="#7" id="57">Types</a> |
| 99 | + <ul class="simple simple-toc-section"> |
| 100 | + <li><a class="reference" href="#Locale" |
| 101 | + title="Locale* = ptr LocaleObj">Locale</a></li> |
| 102 | + <li><a class="reference" href="#LocaleObj" |
| 103 | + title="LocaleObj* = object |
| 104 | + language*: cstring ## A language name, like "en" for English. |
| 105 | + country*: cstring ## A country, like "US" for America. Can be `nil`.">LocaleObj</a></li> |
| 106 | + |
| 107 | + </ul> |
| 108 | +</li> |
| 109 | +<li> |
| 110 | + <a class="reference reference-toplevel" href="#12" id="62">Procs</a> |
| 111 | + <ul class="simple simple-toc-section"> |
| 112 | + <li><a class="reference" href="#getPreferredLocales" |
| 113 | + title="getPreferredLocales*(): Locale">getPreferredLocales</a></li> |
| 114 | + |
| 115 | + </ul> |
| 116 | +</li> |
| 117 | + |
| 118 | +</ul> |
| 119 | + |
| 120 | + </div> |
| 121 | + |
| 122 | + <div class="nine columns" id="content"> |
| 123 | + <div id="tocRoot"></div> |
| 124 | + |
| 125 | + <p class="module-desc"> |
| 126 | +<h1><a class="toc-backref" id="localedotnim" href="#localedotnim">locale.nim</a></h1><p>Include file for SDL locale services</p> |
| 127 | +</p> |
| 128 | + <div class="section" id="7"> |
| 129 | +<h1><a class="toc-backref" href="#7">Types</a></h1> |
| 130 | +<dl class="item"> |
| 131 | +<a id="Locale"></a> |
| 132 | +<dt><pre><span class="Identifier">Locale</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Keyword">ptr</span> <span class="Identifier">LocaleObj</span></pre></dt> |
| 133 | +<dd> |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | +</dd> |
| 138 | +<a id="LocaleObj"></a> |
| 139 | +<dt><pre><span class="Identifier">LocaleObj</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Keyword">object</span> |
| 140 | + <span class="Identifier">language</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">cstring</span> <span class="Comment">## A language name, like "en" for English.</span> |
| 141 | + <span class="Identifier">country</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">cstring</span> <span class="Comment">## A country, like "US" for America. Can be `nil`.</span> |
| 142 | + </pre></dt> |
| 143 | +<dd> |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | +</dd> |
| 148 | + |
| 149 | +</dl></div> |
| 150 | +<div class="section" id="12"> |
| 151 | +<h1><a class="toc-backref" href="#12">Procs</a></h1> |
| 152 | +<dl class="item"> |
| 153 | +<a id="getPreferredLocales"></a> |
| 154 | +<dt><pre><span class="Keyword">proc</span> <a href="#getPreferredLocales"><span class="Identifier">getPreferredLocales</span></a><span class="Operator">*</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Locale</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">cdecl</span><span class="Other">,</span> <span class="Identifier">importc</span><span class="Other">:</span> <span class="StringLit">"SDL_GetPreferredLocales"</span><span class="Other">,</span> |
| 155 | + <span class="Identifier">dynlib</span><span class="Other">:</span> <span class="Identifier">SDL2_LIB</span></span><span class="Other">.}</span></span></pre></dt> |
| 156 | +<dd> |
| 157 | + |
| 158 | +<p>Report the user's preferred locale.</p> |
| 159 | +<p>This returns an array of <tt class="docutils literal"><span class="pre">sdl.Locale</span></tt> objects, the final item zeroed out. When the caller is done with this array, it should call <tt class="docutils literal"><span class="pre">sdl.free()</span></tt> on the returned value; all the memory involved is allocated in a single block, so a single <tt class="docutils literal"><span class="pre">sdl.free()</span></tt> will suffice.</p> |
| 160 | +<p>Returned language strings are in the format xx, where 'xx' is an ISO-639 language specifier (such as "en" for English, "de" for German, etc). Country strings are in the format YY, where "YY" is an ISO-3166 country code (such as "US" for the United States, "CA" for Canada, etc). Country might be <tt class="docutils literal"><span class="pre">nil</span></tt> if there's no specific guidance on them (so you might get { "en", "US" } for American English, but { "en", <tt class="docutils literal"><span class="pre">nil</span></tt> } means "English language, generically"). Language strings are never <tt class="docutils literal"><span class="pre">nil</span></tt>, except to terminate the array.</p> |
| 161 | +<p>Please note that not all of these strings are 2 characters; some are three or more.</p> |
| 162 | +<p>The returned list of locales are in the order of the user's preference. For example, a German citizen that is fluent in US English and knows enough Japanese to navigate around Tokyo might have a list like: { "de", "en_US", "jp", <tt class="docutils literal"><span class="pre">nil</span></tt> }. Someone from England might prefer British English (where "color" is spelled "colour", etc), but will settle for anything like it: { "en_GB", "en", <tt class="docutils literal"><span class="pre">nil</span></tt> }.</p> |
| 163 | +<p>This procedure returns <tt class="docutils literal"><span class="pre">nil</span></tt> on error, including when the platform does not supply this information at all.</p> |
| 164 | +<p>This might be a "slow" call that has to query the operating system. It's best to ask for this once and save the results. However, this list can change, usually because the user has changed a system preference outside of your program; SDL will send an <tt class="docutils literal"><span class="pre">sdl.LOCALECHANGED</span></tt> event in this case, if possible, and you can call this procedure again to get an updated copy of preferred locales.</p> |
| 165 | +<p><tt class="docutils literal"><span class="pre">Return</span></tt> array of locales, terminated with a locale with a <tt class="docutils literal"><span class="pre">nil</span></tt> language field. Will return <tt class="docutils literal"><span class="pre">nil</span></tt> on error.</p> |
| 166 | + |
| 167 | + |
| 168 | +</dd> |
| 169 | + |
| 170 | +</dl></div> |
| 171 | + |
| 172 | + </div> |
| 173 | +</div> |
| 174 | + |
| 175 | + <div class="row"> |
| 176 | + <div class="twelve-columns footer"> |
| 177 | + <span class="nim-sprite"></span> |
| 178 | + <br/> |
| 179 | + <small style="color: var(--hint);">Made with Nim. Generated: 2020-12-27 16:44:22 UTC</small> |
| 180 | + </div> |
| 181 | + </div> |
| 182 | + </div> |
| 183 | +</div> |
| 184 | + |
| 185 | +</body> |
| 186 | +</html> |
0 commit comments