mirror of
https://scm.univ-tours.fr/22107988t/rappaurio-sae501_502.git
synced 2025-08-29 20:45:58 +02:00
137 lines
20 KiB
HTML
137 lines
20 KiB
HTML
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style>
|
||
.KEYW {color: #933;}
|
||
.COMM {color: #bbb; font-style: italic;}
|
||
.NUMB {color: #393;}
|
||
.STRN {color: #393;}
|
||
.REGX {color: #339;}
|
||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||
</style></head><body><pre><span class='line'> 1</span> <span class="TOKN"></span><span class="WHIT">
|
||
<span class='line'> 2</span> </span><span class="COMM">/**
|
||
<span class='line'> 3</span> * @name CeL function for locale
|
||
<span class='line'> 4</span> * @fileoverview
|
||
<span class='line'> 5</span> * 本檔案包含了 locale 的 functions。
|
||
<span class='line'> 6</span> * @since
|
||
<span class='line'> 7</span> */</span><span class="WHIT">
|
||
<span class='line'> 8</span>
|
||
<span class='line'> 9</span> </span><span class="COMM">/*
|
||
<span class='line'> 10</span> http://blog.miniasp.com/post/2010/12/24/Search-and-Download-International-Terminology-Microsoft-Language-Portal.aspx
|
||
<span class='line'> 11</span> http://www.microsoft.com/language/zh-tw/default.aspx
|
||
<span class='line'> 12</span> Microsoft | 語言入口網站
|
||
<span class='line'> 13</span> */</span><span class="WHIT">
|
||
<span class='line'> 14</span>
|
||
<span class='line'> 15</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">CeL</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
|
||
<span class='line'> 16</span> </span><span class="NAME">CeL.setup_module</span><span class="PUNC">(</span><span class="STRN">'application.locale'</span><span class="PUNC">,</span><span class="WHIT">
|
||
<span class='line'> 17</span> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">library_namespace</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">load_arguments</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 18</span>
|
||
<span class='line'> 19</span>
|
||
<span class='line'> 20</span> </span><span class="COMM">// nothing required</span><span class="WHIT">
|
||
<span class='line'> 21</span>
|
||
<span class='line'> 22</span>
|
||
<span class='line'> 23</span>
|
||
<span class='line'> 24</span>
|
||
<span class='line'> 25</span>
|
||
<span class='line'> 26</span> </span><span class="COMM">/**
|
||
<span class='line'> 27</span> * null module constructor
|
||
<span class='line'> 28</span> * @class locale 的 functions
|
||
<span class='line'> 29</span> */</span><span class="WHIT">
|
||
<span class='line'> 30</span> </span><span class="NAME">CeL.application.locale</span><span class="WHIT">
|
||
<span class='line'> 31</span> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 32</span> </span><span class="WHIT"> </span><span class="COMM">// null module constructor</span><span class="WHIT">
|
||
<span class='line'> 33</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 34</span>
|
||
<span class='line'> 35</span> </span><span class="COMM">/**
|
||
<span class='line'> 36</span> * for JSDT: 有 prototype 才會將之當作 Class
|
||
<span class='line'> 37</span> */</span><span class="WHIT">
|
||
<span class='line'> 38</span> </span><span class="NAME">CeL.application.locale</span><span class="WHIT">
|
||
<span class='line'> 39</span> </span><span class="PUNC">.</span><span class="NAME">prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 40</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 41</span>
|
||
<span class='line'> 42</span>
|
||
<span class='line'> 43</span>
|
||
<span class='line'> 44</span>
|
||
<span class='line'> 45</span>
|
||
<span class='line'> 46</span> </span><span class="COMM">// i18n系列 ==================</span><span class="WHIT">
|
||
<span class='line'> 47</span>
|
||
<span class='line'> 48</span> </span><span class="COMM">/* setup message of various languages for i18n (internationalization)
|
||
<span class='line'> 49</span> var languagesMessage={},defaultLanguage,useLanguage,languageAlias;
|
||
<span class='line'> 50</span> setObjValue('languageAlias','en_US=en_US,en=en_US,English=en_US,zh_TW=zh_TW,zh=zh_TW,tw=zh_TW,中文=zh_TW,Chinese=zh_TW,日本語=ja_JP,Japanese=ja_JP,ja_JP=ja_JP,ja=ja_JP,jp=ja_JP');
|
||
<span class='line'> 51</span> */</span><span class="WHIT">
|
||
<span class='line'> 52</span> </span><span class="COMM">//get_language_alias[generateCode.dLK]='languageAlias,existLanguageAlias';</span><span class="WHIT">
|
||
<span class='line'> 53</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">get_language_alias</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">existLanguageAlias</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="NAME">language</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">languageAlias</span><span class="PUNC">[</span><span class="NAME">language</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">language</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 57</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'> 58</span>
|
||
<span class='line'> 59</span> </span><span class="COMM">//existLanguageAlias[generateCode.dLK]='languageAlias';</span><span class="WHIT">
|
||
<span class='line'> 60</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">existLanguageAlias</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">language</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">language</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">languageAlias</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 62</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'> 63</span>
|
||
<span class='line'> 64</span> </span><span class="COMM">// (language, if you want to setup defaultLanguage as well)</span><span class="WHIT">
|
||
<span class='line'> 65</span> </span><span class="COMM">//set_language[generateCode.dLK]='get_language_alias,defaultLanguage,useLanguage';</span><span class="WHIT">
|
||
<span class='line'> 66</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">set_language</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="NAME">language</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_language_alias</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mode</span><span class="PUNC">)</span><span class="WHIT">
|
||
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="NAME">defaultLanguage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">language</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">useLanguage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">language</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">useLanguage</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 73</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'> 74</span>
|
||
<span class='line'> 75</span> </span><span class="COMM">// setMessage(messageIndex1,[local,message],[local,message],messageIndex2,[local,message],[local,message],..)</span><span class="WHIT">
|
||
<span class='line'> 76</span> </span><span class="COMM">//setMessage[generateCode.dLK]='languagesMessage,defaultLanguage,get_language_alias';</span><span class="WHIT">
|
||
<span class='line'> 77</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">setMessage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="COMM">//if(!defaultLanguage)defaultLanguage='en_US';</span><span class="WHIT">
|
||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="COMM">// n.preference('intl.charset.default') http://chaichan.hp.infoseek.co.jp/qa3500/qa3803.htm http://articles.techrepublic.com.com/5100-22-5069931.html</span><span class="WHIT">
|
||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="COMM">// http://forum.mozilla.gr.jp/?mode=al2&namber=5608&rev=&&KLOG=39</span><span class="WHIT">
|
||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="COMM">// navigator.language=general.useragent.locale @ about:config</span><span class="WHIT">
|
||
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="COMM">// var n=window.navigator;netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead');set_language((n.browserLanguage||(n.preference&&n.preference('intl.accept_languages')?n.preference('intl.accept_languages').split(',')[0]:n.language?n.language.replace(/-/,'_'):'')));</span><span class="WHIT">
|
||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">languagesMessage</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">languagesMessage</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">msgNow</span><span class="PUNC">,</span><span class="NAME">language</span><span class="PUNC">,</span><span class="NAME">msg</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC"><</span><span class="NAME">arguments.length</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">msg</span><span class="PUNC">=</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="COMM">//alert(typeof msg+','+msg.constructor+','+msg);</span><span class="WHIT">
|
||
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="NAME">msgNow</span><span class="PUNC">=</span><span class="NAME">msg</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">msg</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="NAME">language</span><span class="PUNC">=</span><span class="NAME">msg</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="NAME">msg</span><span class="PUNC">=</span><span class="NAME">msg</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="COMM">//alert(language+','+msg);</span><span class="WHIT">
|
||
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">==</span><span class="NAME">defaultLanguage</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="NAME">language</span><span class="PUNC">)</span><span class="NAME">msgNow</span><span class="PUNC">=</span><span class="NAME">msg</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">msgNow</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">language</span><span class="PUNC">=</span><span class="NAME">get_language_alias</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">languagesMessage</span><span class="PUNC">[</span><span class="NAME">language</span><span class="PUNC">]</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">languagesMessage</span><span class="PUNC">[</span><span class="NAME">language</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="COMM">//alert('['+language+']['+msgNow+']='+msg);</span><span class="WHIT">
|
||
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="NAME">languagesMessage</span><span class="PUNC">[</span><span class="NAME">language</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">msgNow</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">msg</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'>101</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'>102</span>
|
||
<span class='line'>103</span> </span><span class="COMM">//get_local_message[generateCode.dLK]='languagesMessage,useLanguage,get_language_alias';</span><span class="WHIT">
|
||
<span class='line'>104</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">get_local_message</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">language</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">language</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_language_alias</span><span class="PUNC">(</span><span class="NAME">language</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="COMM">// alert(languagesMessage[language||useLanguage]);</span><span class="WHIT">
|
||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">languagesMessage</span><span class="PUNC">[</span><span class="NAME">language</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">useLanguage</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">message</span><span class="PUNC">]</span><span class="WHIT">
|
||
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'>113</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'>114</span>
|
||
<span class='line'>115</span>
|
||
<span class='line'>116</span> </span><span class="COMM">// ↑i18n系列 ==================</span><span class="WHIT">
|
||
<span class='line'>117</span>
|
||
<span class='line'>118</span>
|
||
<span class='line'>119</span>
|
||
<span class='line'>120</span>
|
||
<span class='line'>121</span>
|
||
<span class='line'>122</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
|
||
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="NAME">CeL.application.locale</span><span class="WHIT">
|
||
<span class='line'>124</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'>125</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||
<span class='line'>126</span>
|
||
<span class='line'>127</span>
|
||
<span class='line'>128</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||
<span class='line'>129</span>
|
||
<span class='line'>130</span> </span></pre></body></html> |