网站为了国际化的需要,会使用到语言包,案例如下图。

这次尝试用js来打语言包,用到了插件 jquery.i18n.properties ,很明显,使用这个插件需要先加载jquery。

代码布局结构

 

代码下载
那就来看一下具体代码吧:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
  5. <title>js 语言包测试</title>
  6. <style>
  7. .zh .zh_png{
  8. display:block;
  9. }
  10. .zh .en_png{
  11. display:none;
  12. }
  13. .en .zh_png{
  14. display:none;
  15. }
  16. .en .en_png{
  17. display:block;
  18. }
  19.  
  20. .img_bg{
  21. background-position:0 0;
  22. width:30px;
  23. height:30px;
  24. }
  25. .zh .img_bg{
  26. background-image:url('img/img_bg_zh.png');
  27. }
  28. .en .img_bg{
  29. background-image:url('img/img_bg_en.png');
  30. }
  31. </style>
  32. </head>
  33.  
  34. <body class="zh">
  35. <div class="wrap">
  36. <h1 data-lang="string_lang1">标题</h1>
  37. <p data-lang="string_lang2">段落内容,balabala</p>
  38. <ul class="nav">
  39. <li><a data-lang="string_lang3">导航1</a></li>
  40. <li><a data-lang="string_lang4">导航2</a></li>
  41. <li><a data-lang="string_lang5">导航3</a></li>
  42. <li><a data-lang="string_lang6">导航4</a></li>
  43. </ul>
  44. <img class="zh_png" src="img/img1_zh.png" />
  45. <img class="en_png" src="img/img1_en.png" />
  46. <div class="screen1">
  47. <div class="inner">
  48. <h1 data-lang="string_lang7">第一屏</h1>
  49. <p data-lang="string_lang8">第一屏内容</p>
  50. </div>
  51. </div>
  52. <div class="img_bg"></div>
  53. </div>
  54. <a id="J_lang_switch" data-lang="string_lang9">切换到英文</a>
  55. <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
  56. <script src="js/jquery.i18n.properties-1.0.9.js"></script>
  57. <script>
  58. var language_pack = {
  59. now_lang : 0, // 0:ch,1:en
  60. loadProperties : function(new_lang){
  61. var self = this;
  62. var tmp_lang = '';
  63. if(new_lang == 0){
  64. tmp_lang = 'zh';
  65. $('body').removeClass('en').addClass('zh');
  66. }else{
  67. tmp_lang = 'en';
  68. $('body').removeClass('zh').addClass('en');
  69. }
  70. jQuery.i18n.properties({//加载资浏览器语言对应的资源文件
  71. name: 'strings', //资源文件名称
  72. path:'language/', //资源文件路径
  73. language: tmp_lang,
  74. cache: false,
  75. mode:'map', //用Map的方式使用资源文件中的值
  76. callback: function() {//加载成功后设置显示内容
  77. for(var i in $.i18n.map){
  78. $('[data-lang="'+i+'"]').text($.i18n.map[i]);
  79. }
  80. document.title = $.i18n.map['string_title'];
  81. }
  82. });
  83. self.now_lang = new_lang;
  84. }
  85. }
  86. $(document).ready(function(){
  87. language_pack.loadProperties(0);
  88.  
  89. $('#J_lang_switch').click(function(){
  90. var new_lang;
  91. if(language_pack.now_lang == 0){
  92. new_lang = 1;
  93. }else{
  94. new_lang = 0;
  95. }
  96. language_pack.loadProperties(new_lang);
  97. });
  98. });
  99. </script>
  100. </body>
  101. </html>

中文语言包 strings_zh.properties

  1. string_title=js 语言包测试
  2. string_lang1=标题
  3. string_lang2=段落内容,balabala
  4. string_lang3=导航1
  5. string_lang4=导航2
  6. string_lang5=导航3
  7. string_lang6=导航4
  8. string_lang7=第一屏
  9. string_lang8=第一屏内容
  10. string_lang9=切换到英文

英文语言包 strings_en.properties

  1. string_title=js language test
  2. string_lang1=title
  3. string_lang2=contentbalabala
  4. string_lang3=nav1
  5. string_lang4=nav2
  6. string_lang5=nav3
  7. string_lang6=nav4
  8. string_lang7=screen1
  9. string_lang8=screen content
  10. string_lang9=change to Chinese
  1. /******************************************************************************
  2. * jquery.i18n.properties
  3. *
  4. * Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
  5. * MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
  6. *
  7. * @version 1.0.x
  8. * @author Nuno Fernandes
  9. * @url www.codingwithcoffee.com
  10. * @inspiration Localisation assistance for jQuery (http://keith-wood.name/localisation.html)
  11. * by Keith Wood (kbwood{at}iinet.com.au) June 2007
  12. *
  13. *****************************************************************************/
  14.  
  15. (function($) {
  16. $.i18n = {};
  17.  
  18. /** Map holding bundle keys (if mode: 'map') */
  19. $.i18n.map = {};
  20.  
  21. /**
  22. * Load and parse message bundle files (.properties),
  23. * making bundles keys available as javascript variables.
  24. *
  25. * i18n files are named <name>.js, or <name>_<language>.js or <name>_<language>_<country>.js
  26. * Where:
  27. * The <language> argument is a valid ISO Language Code. These codes are the lower-case,
  28. * two-letter codes as defined by ISO-639. You can find a full list of these codes at a
  29. * number of sites, such as: http://www.loc.gov/standards/iso639-2/englangn.html
  30. * The <country> argument is a valid ISO Country Code. These codes are the upper-case,
  31. * two-letter codes as defined by ISO-3166. You can find a full list of these codes at a
  32. * number of sites, such as: http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
  33. *
  34. * Sample usage for a bundles/Messages.properties bundle:
  35. * $.i18n.properties({
  36. * name: 'Messages',
  37. * language: 'en_US',
  38. * path: 'bundles'
  39. * });
  40. * @param name (string/string[], optional) names of file to load (eg, 'Messages' or ['Msg1','Msg2']). Defaults to "Messages"
  41. * @param language (string, optional) language/country code (eg, 'en', 'en_US', 'pt_PT'). if not specified, language reported by the browser will be used instead.
  42. * @param path (string, optional) path of directory that contains file to load
  43. * @param mode (string, optional) whether bundles keys are available as JavaScript variables/functions or as a map (eg, 'vars' or 'map')
  44. * @param cache (boolean, optional) whether bundles should be cached by the browser, or forcibly reloaded on each page load. Defaults to false (i.e. forcibly reloaded)
  45. * @param encoding (string, optional) the encoding to request for bundles. Property file resource bundles are specified to be in ISO-8859-1 format. Defaults to UTF-8 for backward compatibility.
  46. * @param callback (function, optional) callback function to be called after script is terminated
  47. */
  48. $.i18n.properties = function(settings) {
  49. // set up settings
  50. var defaults = {
  51. name: 'Messages',
  52. language: '',
  53. path: '',
  54. mode: 'vars',
  55. cache: false,
  56. encoding: 'UTF-8',
  57. callback: null
  58. };
  59. settings = $.extend(defaults, settings);
  60. if(settings.language === null || settings.language == '') {
  61. settings.language = $.i18n.browserLang();
  62. }
  63. if(settings.language === null) {settings.language='';}
  64.  
  65. // load and parse bundle files
  66. var files = getFiles(settings.name);
  67. for(i=0; i<files.length; i++) {
  68. // 1. load base (eg, Messages.properties)
  69. // 此行为博主注释
  70. // loadAndParseFile(settings.path + files[i] + '.properties', settings);
  71. // 2. with language code (eg, Messages_pt.properties)
  72. if(settings.language.length >= 2) {
  73. loadAndParseFile(settings.path + files[i] + '_' + settings.language.substring(0, 2) +'.properties', settings);
  74. }
  75. // 3. with language code and country code (eg, Messages_pt_PT.properties)
  76. if(settings.language.length >= 5) {
  77. loadAndParseFile(settings.path + files[i] + '_' + settings.language.substring(0, 5) +'.properties', settings);
  78. }
  79. }
  80.  
  81. // call callback
  82. if(settings.callback){ settings.callback(); }
  83. };
  84.  
  85. /**
  86. * When configured with mode: 'map', allows access to bundle values by specifying its key.
  87. * Eg, jQuery.i18n.prop('com.company.bundles.menu_add')
  88. */
  89. $.i18n.prop = function(key /* Add parameters as function arguments as necessary */) {
  90. var value = $.i18n.map[key];
  91. if (value == null)
  92. return '[' + key + ']';
  93.  
  94. // if(arguments.length < 2) // No arguments.
  95. // //if(key == 'spv.lbl.modified') {alert(value);}
  96. // return value;
  97.  
  98. // if (!$.isArray(placeHolderValues)) {
  99. // // If placeHolderValues is not an array, make it into one.
  100. // placeHolderValues = [placeHolderValues];
  101. // for (var i=2; i<arguments.length; i++)
  102. // placeHolderValues.push(arguments[i]);
  103. // }
  104.  
  105. // Place holder replacement
  106. /**
  107. * Tested with:
  108. * test.t1=asdf ''{0}''
  109. * test.t2=asdf '{0}' '{1}'{1}'zxcv
  110. * test.t3=This is \"a quote" 'a''{0}''s'd{fgh{ij'
  111. * test.t4="'''{'0}''" {0}{a}
  112. * test.t5="'''{0}'''" {1}
  113. * test.t6=a {1} b {0} c
  114. * test.t7=a 'quoted \\ s\ttringy' \t\t x
  115. *
  116. * Produces:
  117. * test.t1, p1 ==> asdf 'p1'
  118. * test.t2, p1 ==> asdf {0} {1}{1}zxcv
  119. * test.t3, p1 ==> This is "a quote" a'{0}'sd{fgh{ij
  120. * test.t4, p1 ==> "'{0}'" p1{a}
  121. * test.t5, p1 ==> "'{0}'" {1}
  122. * test.t6, p1 ==> a {1} b p1 c
  123. * test.t6, p1, p2 ==> a p2 b p1 c
  124. * test.t6, p1, p2, p3 ==> a p2 b p1 c
  125. * test.t7 ==> a quoted \ s tringy x
  126. */
  127.  
  128. var i;
  129. if (typeof(value) == 'string') {
  130. // Handle escape characters. Done separately from the tokenizing loop below because escape characters are
  131. // active in quoted strings.
  132. i = 0;
  133. while ((i = value.indexOf('\\', i)) != -1) {
  134. if (value[i+1] == 't')
  135. value = value.substring(0, i) + '\t' + value.substring((i++) + 2); // tab
  136. else if (value[i+1] == 'r')
  137. value = value.substring(0, i) + '\r' + value.substring((i++) + 2); // return
  138. else if (value[i+1] == 'n')
  139. value = value.substring(0, i) + '\n' + value.substring((i++) + 2); // line feed
  140. else if (value[i+1] == 'f')
  141. value = value.substring(0, i) + '\f' + value.substring((i++) + 2); // form feed
  142. else if (value[i+1] == '\\')
  143. value = value.substring(0, i) + '\\' + value.substring((i++) + 2); // \
  144. else
  145. value = value.substring(0, i) + value.substring(i+1); // Quietly drop the character
  146. }
  147.  
  148. // Lazily convert the string to a list of tokens.
  149. var arr = [], j, index;
  150. i = 0;
  151. while (i < value.length) {
  152. if (value[i] == '\'') {
  153. // Handle quotes
  154. if (i == value.length-1)
  155. value = value.substring(0, i); // Silently drop the trailing quote
  156. else if (value[i+1] == '\'')
  157. value = value.substring(0, i) + value.substring(++i); // Escaped quote
  158. else {
  159. // Quoted string
  160. j = i + 2;
  161. while ((j = value.indexOf('\'', j)) != -1) {
  162. if (j == value.length-1 || value[j+1] != '\'') {
  163. // Found start and end quotes. Remove them
  164. value = value.substring(0,i) + value.substring(i+1, j) + value.substring(j+1);
  165. i = j - 1;
  166. break;
  167. }
  168. else {
  169. // Found a double quote, reduce to a single quote.
  170. value = value.substring(0,j) + value.substring(++j);
  171. }
  172. }
  173.  
  174. if (j == -1) {
  175. // There is no end quote. Drop the start quote
  176. value = value.substring(0,i) + value.substring(i+1);
  177. }
  178. }
  179. }
  180. else if (value[i] == '{') {
  181. // Beginning of an unquoted place holder.
  182. j = value.indexOf('}', i+1);
  183. if (j == -1)
  184. i++; // No end. Process the rest of the line. Java would throw an exception
  185. else {
  186. // Add 1 to the index so that it aligns with the function arguments.
  187. index = parseInt(value.substring(i+1, j));
  188. if (!isNaN(index) && index >= 0) {
  189. // Put the line thus far (if it isn't empty) into the array
  190. var s = value.substring(0, i);
  191. if (s != "")
  192. arr.push(s);
  193. // Put the parameter reference into the array
  194. arr.push(index);
  195. // Start the processing over again starting from the rest of the line.
  196. i = 0;
  197. value = value.substring(j+1);
  198. }
  199. else
  200. i = j + 1; // Invalid parameter. Leave as is.
  201. }
  202. }
  203. else
  204. i++;
  205. }
  206.  
  207. // Put the remainder of the no-empty line into the array.
  208. if (value != "")
  209. arr.push(value);
  210. value = arr;
  211.  
  212. // Make the array the value for the entry.
  213. $.i18n.map[key] = arr;
  214. }
  215.  
  216. if (value.length == 0)
  217. return "";
  218. if (value.lengh == 1 && typeof(value[0]) == "string")
  219. return value[0];
  220.  
  221. var s = "";
  222. for (i=0; i<value.length; i++) {
  223. if (typeof(value[i]) == "string")
  224. s += value[i];
  225. // Must be a number
  226. else if (value[i] + 1 < arguments.length)
  227. s += arguments[value[i] + 1];
  228. else
  229. s += "{"+ value[i] +"}";
  230. }
  231.  
  232. return s;
  233. };
  234.  
  235. /** Language reported by browser, normalized code */
  236. $.i18n.browserLang = function() {
  237. return normaliseLanguageCode(navigator.language /* Mozilla */ || navigator.userLanguage /* IE */);
  238. }
  239.  
  240. /** Load and parse .properties files */
  241. function loadAndParseFile(filename, settings) {
  242. $.ajax({
  243. url: filename,
  244. async: false,
  245. cache: settings.cache,
  246. contentType:'text/plain;charset='+ settings.encoding,
  247. dataType: 'text',
  248. success: function(data, status) {
  249. parseData(data, settings.mode);
  250. }
  251. });
  252. }
  253.  
  254. /** Parse .properties files */
  255. function parseData(data, mode) {
  256. var parsed = '';
  257. var parameters = data.split( /\n/ );
  258. var regPlaceHolder = /(\{\d+\})/g;
  259. var regRepPlaceHolder = /\{(\d+)\}/g;
  260. var unicodeRE = /(\\u.{4})/ig;
  261. for(var i=0; i<parameters.length; i++ ) {
  262. parameters[i] = parameters[i].replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); // trim
  263. if(parameters[i].length > 0 && parameters[i].match("^#")!="#") { // skip comments
  264. var pair = parameters[i].split('=');
  265. if(pair.length > 0) {
  266. /** Process key & value */
  267. var name = unescape(pair[0]).replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); // trim
  268. var value = pair.length == 1 ? "" : pair[1];
  269. // process multi-line values
  270. while(value.match(/\\$/)=="\\") {
  271. value = value.substring(0, value.length - 1);
  272. value += parameters[++i].replace( /\s\s*$/, '' ); // right trim
  273. }
  274. // Put values with embedded '='s back together
  275. for(var s=2;s<pair.length;s++){ value +='=' + pair[s]; }
  276. value = value.replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); // trim
  277.  
  278. /** Mode: bundle keys in a map */
  279. if(mode == 'map' || mode == 'both') {
  280. // handle unicode chars possibly left out
  281. var unicodeMatches = value.match(unicodeRE);
  282. if(unicodeMatches) {
  283. for(var u=0; u<unicodeMatches.length; u++) {
  284. value = value.replace( unicodeMatches[u], unescapeUnicode(unicodeMatches[u]));
  285. }
  286. }
  287. // add to map
  288. $.i18n.map[name] = value;
  289. }
  290.  
  291. /** Mode: bundle keys as vars/functions */
  292. if(mode == 'vars' || mode == 'both') {
  293. value = value.replace( /"/g, '\\"' ); // escape quotation mark (")
  294.  
  295. // make sure namespaced key exists (eg, 'some.key')
  296. checkKeyNamespace(name);
  297.  
  298. // value with variable substitutions
  299. if(regPlaceHolder.test(value)) {
  300. var parts = value.split(regPlaceHolder);
  301. // process function args
  302. var first = true;
  303. var fnArgs = '';
  304. var usedArgs = [];
  305. for(var p=0; p<parts.length; p++) {
  306. if(regPlaceHolder.test(parts[p]) && (usedArgs.length == 0 || usedArgs.indexOf(parts[p]) == -1)) {
  307. if(!first) {fnArgs += ',';}
  308. fnArgs += parts[p].replace(regRepPlaceHolder, 'v$1');
  309. usedArgs.push(parts[p]);
  310. first = false;
  311. }
  312. }
  313. parsed += name + '=function(' + fnArgs + '){';
  314. // process function body
  315. var fnExpr = '"' + value.replace(regRepPlaceHolder, '"+v$1+"') + '"';
  316. parsed += 'return ' + fnExpr + ';' + '};';
  317.  
  318. // simple value
  319. }else{
  320. parsed += name+'="'+value+'";';
  321. }
  322. } // END: Mode: bundle keys as vars/functions
  323. } // END: if(pair.length > 0)
  324. } // END: skip comments
  325. }
  326. eval(parsed);
  327. }
  328.  
  329. /** Make sure namespace exists (for keys with dots in name) */
  330. // TODO key parts that start with numbers quietly fail. i.e. month.short.1=Jan
  331. function checkKeyNamespace(key) {
  332. var regDot = /\./;
  333. if(regDot.test(key)) {
  334. var fullname = '';
  335. var names = key.split( /\./ );
  336. for(var i=0; i<names.length; i++) {
  337. if(i>0) {fullname += '.';}
  338. fullname += names[i];
  339. if(eval('typeof '+fullname+' == "undefined"')) {
  340. eval(fullname + '={};');
  341. }
  342. }
  343. }
  344. }
  345.  
  346. /** Make sure filename is an array */
  347. function getFiles(names) {
  348. return (names && names.constructor == Array) ? names : [names];
  349. }
  350.  
  351. /** Ensure language code is in the format aa_AA. */
  352. function normaliseLanguageCode(lang) {
  353. lang = lang.toLowerCase();
  354. if(lang.length > 3) {
  355. lang = lang.substring(0, 3) + lang.substring(3).toUpperCase();
  356. }
  357. return lang;
  358. }
  359.  
  360. /** Unescape unicode chars ('\u00e3') */
  361. function unescapeUnicode(str) {
  362. // unescape unicode codes
  363. var codes = [];
  364. var code = parseInt(str.substr(2), 16);
  365. if (code >= 0 && code < Math.pow(2, 16)) {
  366. codes.push(code);
  367. }
  368. // convert codes to text
  369. var unescaped = '';
  370. for (var i = 0; i < codes.length; ++i) {
  371. unescaped += String.fromCharCode(codes[i]);
  372. }
  373. return unescaped;
  374. }
  375.  
  376. /* Cross-Browser Split 1.0.1
  377. (c) Steven Levithan <stevenlevithan.com>; MIT License
  378. An ECMA-compliant, uniform cross-browser split method */
  379. var cbSplit;
  380. // avoid running twice, which would break `cbSplit._nativeSplit`'s reference to the native `split`
  381. if (!cbSplit) {
  382. cbSplit = function(str, separator, limit) {
  383. // if `separator` is not a regex, use the native `split`
  384. if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
  385. if(typeof cbSplit._nativeSplit == "undefined")
  386. return str.split(separator, limit);
  387. else
  388. return cbSplit._nativeSplit.call(str, separator, limit);
  389. }
  390.  
  391. var output = [],
  392. lastLastIndex = 0,
  393. flags = (separator.ignoreCase ? "i" : "") +
  394. (separator.multiline ? "m" : "") +
  395. (separator.sticky ? "y" : ""),
  396. separator = RegExp(separator.source, flags + "g"), // make `global` and avoid `lastIndex` issues by working with a copy
  397. separator2, match, lastIndex, lastLength;
  398.  
  399. str = str + ""; // type conversion
  400. if (!cbSplit._compliantExecNpcg) {
  401. separator2 = RegExp("^" + separator.source + "$(?!\\s)", flags); // doesn't need /g or /y, but they don't hurt
  402. }
  403.  
  404. /* behavior for `limit`: if it's...
  405. - `undefined`: no limit.
  406. - `NaN` or zero: return an empty array.
  407. - a positive number: use `Math.floor(limit)`.
  408. - a negative number: no limit.
  409. - other: type-convert, then use the above rules. */
  410. if (limit === undefined || +limit < 0) {
  411. limit = Infinity;
  412. } else {
  413. limit = Math.floor(+limit);
  414. if (!limit) {
  415. return [];
  416. }
  417. }
  418.  
  419. while (match = separator.exec(str)) {
  420. lastIndex = match.index + match[0].length; // `separator.lastIndex` is not reliable cross-browser
  421.  
  422. if (lastIndex > lastLastIndex) {
  423. output.push(str.slice(lastLastIndex, match.index));
  424.  
  425. // fix browsers whose `exec` methods don't consistently return `undefined` for nonparticipating capturing groups
  426. if (!cbSplit._compliantExecNpcg && match.length > 1) {
  427. match[0].replace(separator2, function () {
  428. for (var i = 1; i < arguments.length - 2; i++) {
  429. if (arguments[i] === undefined) {
  430. match[i] = undefined;
  431. }
  432. }
  433. });
  434. }
  435.  
  436. if (match.length > 1 && match.index < str.length) {
  437. Array.prototype.push.apply(output, match.slice(1));
  438. }
  439.  
  440. lastLength = match[0].length;
  441. lastLastIndex = lastIndex;
  442.  
  443. if (output.length >= limit) {
  444. break;
  445. }
  446. }
  447.  
  448. if (separator.lastIndex === match.index) {
  449. separator.lastIndex++; // avoid an infinite loop
  450. }
  451. }
  452.  
  453. if (lastLastIndex === str.length) {
  454. if (lastLength || !separator.test("")) {
  455. output.push("");
  456. }
  457. } else {
  458. output.push(str.slice(lastLastIndex));
  459. }
  460.  
  461. return output.length > limit ? output.slice(0, limit) : output;
  462. };
  463.  
  464. cbSplit._compliantExecNpcg = /()??/.exec("")[1] === undefined; // NPCG: nonparticipating capturing group
  465. cbSplit._nativeSplit = String.prototype.split;
  466.  
  467. } // end `if (!cbSplit)`
  468. String.prototype.split = function (separator, limit) {
  469. return cbSplit(this, separator, limit);
  470. };
  471.  
  472. })(jQuery);

jquery.i18n.properties-1.0.9.js

原文:https://www.jianshu.com/p/8b4c63e1cf25

demo:https://codepen.io/AndreCortellini/pen/xPMEWK

jquery.i18n.properties的使用讲解与实例:https://blog.csdn.net/m0_37566424/article/details/79070218

js多语言切换demo的更多相关文章

  1. ASP.NET MVC5多语言切换快速实现方案

    功能 实现动态切换语言,Demo做了三种语言库可以切换,包括资源文件的定义,实体对象属性设置,后台代码Controller,IAuthorizationFilter,HtmlHelper的实现,做法比 ...

  2. vue-i18n 国际化语言切换

    vue-i18n 用于前端vue项目中,需要多语言切换的场景 安装方法(npm) npm install vue-i18n 简单使用   1.在vue项目的main.ts文件中实例化 i18n imp ...

  3. react项目实现多语言切换

    网站的语言切换功能大家都见过不少,一般都是一个下拉框选择语言,如果让我们想一下怎么实现这个功能,我相信大家都是有哥大概思路,一个语言切换的select,将当前的选择的语言存在全局,根据这个语言的key ...

  4. bootstrap table 插件多语言切换

    在bootstrap中的bootstrap table 插件在多语言切换的审核,只需要如下操作 引入bootstrap-table-locale-all.js文件 $('#Grid').bootstr ...

  5. 如何实现Echart不刷新页面,多语言切换下的地图数据重新加载,api请求数据加载,soketed数据实时加载

    可视化项目中经常用到ecahrt,各种异步加载,连接socket,多语言切换等问题,现在汇总一下: Ecahrt初始化,全局统一init,可以初始化为0,等待后续数据操作 1.如果是api重新请求,数 ...

  6. vue 国际化i18n 多语言切换

    安装 npm install vue-i18n 新建一个文件夹 i18n ,内新建 en.js zh.js index.js 三个文件 准备翻译信息 en.js export default { ho ...

  7. JS图片Switchable切换大集合

    JS图片切换大集合 利用周末2天把JS图片切换常见效果封装了下,比如:轮播,显示隐藏,淡入淡出等.废话不多说,直接看效果吧!JSFiddler链接如下: 想看JS轮播切换效果请点击我! 当然由于上传图 ...

  8. vue-i18n vue-cli项目中实现国际化 多语言切换功能 一

    vue-cli项目中引入vue-i18n 安装: npm install vue-i18n可参考vue-i18n官网文档 main.js中引入: import Vue from 'vue' impor ...

  9. WPF语言切换,国际化

    winform语言切换在每个窗口下面有一个.resx结尾的资源文件,在上面添加新字符串就好了: WPF语言切换跟winform不一样的地方在于需要自己添加资源文件,并且这个资源文件可以写一个,也可以写 ...

随机推荐

  1. Mac下mysql服务端密码重置及环境配置

    一 停止mysql服务 关闭MySQL服务的操作: 苹果->系统偏好设置->最下边点MySQL 在弹出页面中 关闭mysql服务(点击stop mysql server) 二 进入终端,命 ...

  2. POJ2513:Colored Sticks(字典树+欧拉路径+并查集)

    http://poj.org/problem?id=2513 Description You are given a bunch of wooden sticks. Each endpoint of ...

  3. CentOS / RHEL 配置yum源

    CentOS / RHEL 配置yum源 */--> CentOS / RHEL 配置yum源 Table of Contents 1. 前言 2. 关于yum 2.1. yum是什么 2.2. ...

  4. openstack基于卷快照恢复卷

    openstack基于卷快照恢复卷 基于P版本,对卷基于快照进行恢复的源码分析 1.特性描述 在pike版本中,openstack官网增加了一个新特性,Cinder volume revert to ...

  5. 两个input之间有空隙,处理方法

    修改css,给前边一个input添加一个左浮动.   <input id="day" type="button" value="日" ...

  6. 为什么HashMap继承了AbstractMap还要实现Map?

    前言 之前看源码一直忽略了这个现象,按理说HashMap的父类AbstractMap已经实现了Map,它为什么还要实现一次呢?遂上网查了一下,背后原因让人大跌眼镜. 原因 这是类库设计者的拼写错误,其 ...

  7. selenium 2019 笔记

    1.get打开本地目录的方法

  8. 数据测试001:利用python连接数据库插入excel数据

    数据测试001:利用python连接数据库插入excel数据 最近在做数据测试,主要是做报表系统,需要往数据库插入数据验证服务逻辑,本次介绍如何利用python脚本插入Oracle和Mysql库中: ...

  9. python3 速查参考- python基础 9 -> MySQL基础概念、数据库create、alter、insert、update、delete、select等基础命令

    前置步骤: 下载一个绿色版的mysql数据库客户端连接工具 :http://wosn.net/821.html mysql平台为win7(以后会有CentOS上的) 学习目的: 掌握数据库的基本概念, ...

  10. JAVA各种框架插件常用端口:redis、MySQL、rabbitmq、elasticsearch、tomcat等等

    默认端口号 应用 21 FTP(文件传输) 22 SSH(安全登录).SCP(文件传输).端口重定向 23 Telnet(远程登录) 80 HTTP服务器 1433 SQL Server数据库serv ...