Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

refactor($locale): use en-us as generic built-in locale #12462

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = function(grunt) {
files: { src: 'test/**/*.js' },
},
ng: {
files: { src: files['angularSrc'] },
files: { src: files['angularSrc'].concat('!src/angular.bind') },
},
ngAnimate: {
files: { src: 'src/ngAnimate/**/*.js' },
Expand Down
13 changes: 8 additions & 5 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ var angularFiles = {
'src/ng/directive/script.js',
'src/ng/directive/select.js',
'src/ng/directive/style.js',
'src/ng/directive/validators.js'
'src/ng/directive/validators.js',
'src/angular.bind',
'src/publishExternalApis.js',
'src/ngLocale/angular-locale_en-us.js'
],

'angularLoader': [
Expand Down Expand Up @@ -179,7 +182,6 @@ var angularFiles = {
'bower_components/jquery/dist/jquery.js',
'test/jquery_remove.js',
'@angularSrc',
'src/publishExternalApis.js',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
Expand All @@ -188,7 +190,8 @@ var angularFiles = {
'karmaExclude': [
'test/jquery_alias.js',
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js'
'src/ngScenario/angular-bootstrap.js',
'src/angular.bind'
],

'karmaScenario': [
Expand All @@ -215,7 +218,6 @@ var angularFiles = {
'bower_components/jquery/dist/jquery.js',
'test/jquery_alias.js',
'@angularSrc',
'src/publishExternalApis.js',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
Expand All @@ -224,7 +226,8 @@ var angularFiles = {
'karmaJqueryExclude': [
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js',
'test/jquery_remove.js'
'test/jquery_remove.js',
'src/angular.bind'
]
};

Expand Down
6 changes: 0 additions & 6 deletions src/AngularPublic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/* global angularModule: true,
version: true,

$LocaleProvider,
$CompileProvider,

htmlAnchorDirective,
Expand Down Expand Up @@ -151,11 +150,6 @@ function publishExternalAPI(angular) {
});

angularModule = setupModuleLoader(window);
try {
angularModule('ngLocale');
} catch (e) {
angularModule('ngLocale', []).provider('$locale', $LocaleProvider);
}

angularModule('ng', ['ngLocale'], ['$provide',
function ngModule($provide) {
Expand Down
10 changes: 10 additions & 0 deletions src/angular.bind
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if (window.angular.bootstrap) {
//AngularJS is already loaded, so we can return here...
console.log('WARNING: Tried to load angular more than once.');
return;
}

//try to bind to jquery now so that one can write jqLite(document).ready()
//but we will rebind on bootstrap again.
bindJQuery();

12 changes: 0 additions & 12 deletions src/angular.suffix
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
if (window.angular.bootstrap) {
//AngularJS is already loaded, so we can return here...
console.log('WARNING: Tried to load angular more than once.');
return;
}

//try to bind to jquery now so that one can write jqLite(document).ready()
//but we will rebind on bootstrap again.
bindJQuery();

publishExternalAPI(angular);

jqLite(document).ready(function() {
angularInit(document, bootstrap);
});
Expand Down
68 changes: 0 additions & 68 deletions src/ng/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,4 @@
*
* * `id` – `{string}` – locale id formatted as `languageId-countryId` (e.g. `en-us`)
*/
function $LocaleProvider() {
this.$get = function() {
return {
id: 'en-us',

NUMBER_FORMATS: {
DECIMAL_SEP: '.',
GROUP_SEP: ',',
PATTERNS: [
{ // Decimal Pattern
minInt: 1,
minFrac: 0,
maxFrac: 3,
posPre: '',
posSuf: '',
negPre: '-',
negSuf: '',
gSize: 3,
lgSize: 3
},{ //Currency Pattern
minInt: 1,
minFrac: 2,
maxFrac: 2,
posPre: '\u00A4',
posSuf: '',
negPre: '-\u00A4',
negSuf: '',
gSize: 3,
lgSize: 3
}
],
CURRENCY_SYM: '$'
},

DATETIME_FORMATS: {
MONTH:
'January,February,March,April,May,June,July,August,September,October,November,December'
.split(','),
SHORTMONTH: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
DAY: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
SHORTDAY: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(','),
AMPMS: ['AM','PM'],
medium: 'MMM d, y h:mm:ss a',
'short': 'M/d/yy h:mm a',
fullDate: 'EEEE, MMMM d, y',
longDate: 'MMMM d, y',
mediumDate: 'MMM d, y',
shortDate: 'M/d/yy',
mediumTime: 'h:mm:ss a',
shortTime: 'h:mm a',
ERANAMES: [
"Before Christ",
"Anno Domini"
],
ERAS: [
"BC",
"AD"
]
},

pluralCat: function(num) {
if (num === 1) {
return 'one';
}
return 'other';
}
};
};
}
5 changes: 4 additions & 1 deletion test/ng/localeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
describe('$locale', function() {
/* global $LocaleProvider: false */

var $locale = new $LocaleProvider().$get();
var $locale;
beforeEach(inject(function(_$locale_) {
$locale = _$locale_;
}));

it('should have locale id set to en-us', function() {
expect($locale.id).toBe('en-us');
Expand Down