Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: safari/ext/common.js

Issue 4871895371481088: Convert region code to uppercase when generating translation file URL on Safari (Closed)
Patch Set: Created April 10, 2014, 7:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 /* I18n */ 78 /* I18n */
79 79
80 var localeCandidates = null; 80 var localeCandidates = null;
81 var uiLocale; 81 var uiLocale;
82 82
83 var getLocaleCandidates = function() 83 var getLocaleCandidates = function()
84 { 84 {
85 var candidates = []; 85 var candidates = [];
86 var defaultLocale = "en_US"; 86 var defaultLocale = "en_US";
87 87
88 var bits, i; 88 var match = navigator.language.match(/(.*?)(?:-(.*))?$/);
89 for (i = (bits = navigator.language.split("-")).length; i > 0; i--) 89 var language = match[1];
90 { 90 var region = match[2];
Wladimir Palant 2014/04/10 08:05:34 It seems that you are still trying to split the st
Sebastian Noack 2014/04/10 08:55:52 Done, but I used ES6 array unpacking for better re
91 var locale = bits.slice(0, i).join("_");
92 candidates.push(locale);
93 91
94 if (locale == defaultLocale) 92 if (region)
95 return candidates; 93 candidates.push(language + "_" + region.toUpperCase());
96 }
97 94
98 candidates.push(defaultLocale); 95 candidates.push(language, defaultLocale);
96 candidates.splice(candidates.indexOf(defaultLocale) + 1);
Wladimir Palant 2014/04/10 08:05:34 I had some trouble understanding the purpose of th
Sebastian Noack 2014/04/10 08:55:52 Done, but I used candidates.indexOf(defaultLocale)
97
99 return candidates; 98 return candidates;
100 }; 99 };
101 100
102 var getCatalog = function(locale) 101 var getCatalog = function(locale)
103 { 102 {
104 var xhr = new XMLHttpRequest(); 103 var xhr = new XMLHttpRequest();
105 104
106 xhr.open("GET", safari.extension.baseURI + "_locales/" + locale + "/messages .json", false); 105 xhr.open("GET", safari.extension.baseURI + "_locales/" + locale + "/messages .json", false);
107 106
108 try { 107 try {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 }; 178 };
180 179
181 180
182 /* Utils */ 181 /* Utils */
183 182
184 ext.getURL = function(path) 183 ext.getURL = function(path)
185 { 184 {
186 return safari.extension.baseURI + path; 185 return safari.extension.baseURI + path;
187 }; 186 };
188 })(); 187 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld