Skip to content

Commit

Permalink
refactor($locale): use en-us as generic built-in locale
Browse files Browse the repository at this point in the history
Previously there was a custom built en-us locale that was included with
angular.js. This made likely that it would get out of sync with the real
en-us locale that is generated from the closure library.

This change removes that custom one and uses the generated one instead.
This also has the benefit of preventing the unwanted caught error on trying
to load `ngLocale` during angular bootstrap.

Closes angular#12134
Closes angular#8174
  • Loading branch information
petebacondarwin committed Jul 16, 2015
1 parent 9e492c3 commit 70ce425
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 145 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ module.exports = function(grunt) {
},
angular: {
dest: 'build/angular.js',
src: util.wrap([files['angularSrc']], 'angular'),
src: util.wrap([files['angularSrc']], 'angular')
.concat('src/ngLocale/angular-locale_en-us.js'),
styles: {
css: ['css/angular.css'],
generateCspCssFile: true,
Expand Down
16 changes: 10 additions & 6 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var angularFiles = {
'src/ng/httpBackend.js',
'src/ng/interpolate.js',
'src/ng/interval.js',
'src/ng/locale.js',
'src/ng/location.js',
'src/ng/log.js',
'src/ng/parse.js',
Expand Down Expand Up @@ -182,7 +181,8 @@ var angularFiles = {
'src/publishExternalApis.js',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
'@angularTest',
'src/ngLocale/angular-locale_en-us.js' // we need an ngLocale module
],

'karmaExclude': [
Expand All @@ -193,12 +193,13 @@ var angularFiles = {

'karmaScenario': [
'build/angular-scenario.js',
'build/docs/docs-scenario.js'
'build/docs/docs-scenario.js',
'src/ngLocale/angular-locale_en-us.js' // we need an ngLocale module
],

"karmaModules": [
'build/angular.js',
'@angularSrcModules',
'@angularSrcModules',,
'src/ngScenario/browserTrigger.js',
'test/helpers/*.js',
'test/ngMessageFormat/*.js',
Expand All @@ -208,7 +209,8 @@ var angularFiles = {
'test/ngResource/*.js',
'test/ngSanitize/**/*.js',
'test/ngTouch/**/*.js',
'test/ngAria/*.js'
'test/ngAria/*.js',
'src/ngLocale/angular-locale_en-us.js' // we need an ngLocale module
],

'karmaJquery': [
Expand All @@ -218,7 +220,9 @@ var angularFiles = {
'src/publishExternalApis.js',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
'@angularTest',
'src/ngLocale/angular-locale_en-us.js' // we need an ngLocale module

],

'karmaJqueryExclude': [
Expand Down
6 changes: 3 additions & 3 deletions docs/content/guide/i18n.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ directive}. Additionally, you can use {@link guide/i18n#messageformat-extension
`$interpolate` for localizable pluralization and gender support in all interpolations via the
`ngMessageFormat` module.

All localizable Angular components depend on locale-specific rule sets managed by the {@link
ng.$locale `$locale` service}.
All localizable Angular components depend on locale-specific rule sets managed by the
{@link ngLocale `$locale` service}.

There a few examples that showcase how to use Angular filters with various locale rule sets in the
[`i18n/e2e` directory](https://github.com/angular/angular.js/tree/master/i18n/e2e) of the Angular
Expand Down Expand Up @@ -99,7 +99,7 @@ develop your app.
### Currency symbol

Angular's {@link ng.filter:currency currency filter} allows you to use the default currency symbol
from the {@link ng.$locale locale service}, or you can provide the filter with a custom currency
from the {@link ngLocale `locale` service}, or you can provide the filter with a custom currency
symbol.

<div class="alert alert-success">
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 @@ -150,11 +149,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
81 changes: 0 additions & 81 deletions src/ng/locale.js

This file was deleted.

18 changes: 18 additions & 0 deletions src/ngLocale/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @ngdoc module
* @name ngLocale
*
* @description
* There is a different `ngLocale` module for each of the locales found in the closure library.
* See {@link i18n}
* Each module exposes a `$locale` service, which provides localization rules for various Angular components.
* Right now the only required property of the `$locale` service is:
*
* * `id` – `{string}` – locale id formatted as `languageId-countryId` (e.g. `en-us`)
*
* But most locales expose a number of other useful members such as:
*
* * `DATETIME_FORMATS` property
* * `NUMBER_FORMATS` property
* * `pluralCat` member
*/
48 changes: 0 additions & 48 deletions test/ng/localeSpec.js

This file was deleted.

0 comments on commit 70ce425

Please sign in to comment.