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

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

Issue 4793439480709120: Issue 2008 - Handle language codes without region on Safari (Closed)
Patch Set: Created Feb. 18, 2015, 8:55 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 /* I18n */ 95 /* I18n */
96 96
97 var getLocaleCandidates = function() 97 var getLocaleCandidates = function()
98 { 98 {
99 var candidates = []; 99 var candidates = [];
100 var defaultLocale = "en_US"; 100 var defaultLocale = "en_US";
101 101
102 // e.g. "ja-jp-mac" -> "ja_JP", note that the part after the second 102 // e.g. "ja-jp-mac" -> "ja_JP", note that the part after the second
103 // dash is dropped, since we only support language and region 103 // dash is dropped, since we only support language and region
104 var [language, region] = navigator.language.split("-"); 104 var [language, region] = navigator.language.split("-");
105 region = region.toUpperCase();
106
107 // e.g. "es-AR" -> "es_419", note that we combine all dialects of
108 // Spanish outside of Spain, the same way Google Chrome does,
109 // since we use the same translations as for the Chrome extension
110 if (language == "es" && region && region != "ES")
111 region = "419";
112 105
113 if (region) 106 if (region)
107 {
108 region = region.toUpperCase();
109
110 // e.g. "es-AR" -> "es_419", note that we combine all dialects of
111 // Spanish outside of Spain, the same way Google Chrome does,
112 // since we use the same translations as for the Chrome extension
113 if (language == "es" && region != "ES")
114 region = "419";
115
114 candidates.push(language + "_" + region); 116 candidates.push(language + "_" + region);
117 }
115 118
116 candidates.push(language); 119 candidates.push(language);
117 120
118 if (candidates.indexOf(defaultLocale) == -1) 121 if (candidates.indexOf(defaultLocale) == -1)
119 candidates.push(defaultLocale); 122 candidates.push(defaultLocale);
120 123
121 return candidates; 124 return candidates;
122 }; 125 };
123 126
124 var initCatalog = function(uiLocale) 127 var initCatalog = function(uiLocale)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 }; 214 };
212 215
213 216
214 /* Utils */ 217 /* Utils */
215 218
216 ext.getURL = function(path) 219 ext.getURL = function(path)
217 { 220 {
218 return safari.extension.baseURI + path; 221 return safari.extension.baseURI + path;
219 }; 222 };
220 })(); 223 })();
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