394 Commits

Author SHA1 Message Date
Olivier Combe
079d884b6c feat(common): drop use of the Intl API to improve browser support (#18284)
BREAKING CHANGE: Because of multiple bugs and browser inconsistencies, we have dropped the intl api in favor of data exported from the Unicode Common Locale Data Repository (CLDR).
Unfortunately we had to change the i18n pipes (date, number, currency, percent) and there are some breaking changes.

1. I18n pipes
* Breaking change:
  - By default Angular now only contains locale data for the language `en-US`, if you set the value of `LOCALE_ID` to another locale, you will have to import new locale data for this language because we don't use the intl API anymore.

* Features:
  - you don't need to use the intl polyfill for Angular anymore.
  - all i18n pipes now have an additional last parameter `locale` which allows you to use a specific locale instead of the one defined in the token `LOCALE_ID` (whose value is `en-US` by default).
  - the new locale data extracted from CLDR are now available to developers as well and can be used through an API (which should be especially useful for library authors).
  - you can still use the old pipes for now, but their names have been changed and they are no longer included in the `CommonModule`. To use them, you will have to import the `DeprecatedI18NPipesModule` after the `CommonModule` (the order is important):

  ```ts
  import { NgModule } from '@angular/core';
  import { CommonModule, DeprecatedI18NPipesModule } from '@angular/common';

  @NgModule({
    imports: [
      CommonModule,
      // import deprecated module after
      DeprecatedI18NPipesModule
    ]
  })
  export class AppModule { }
  ```

  Dont forget that you will still need to import the intl API polyfill if you want to use those deprecated pipes.

2. Date pipe
* Breaking changes:
  - the predefined formats (`short`, `shortTime`, `shortDate`, `medium`, ...) now use the patterns given by CLDR (like it was in AngularJS) instead of the ones from the intl API. You might notice some changes, e.g. `shortDate` will be `8/15/17` instead of `8/15/2017` for `en-US`.
  - the narrow version of eras is now `GGGGG` instead of `G`, the format `G` is now similar to `GG` and `GGG`.
  - the narrow version of months is now `MMMMM` instead of `L`, the format `L` is now the short standalone version of months.
  - the narrow version of the week day is now `EEEEE` instead of `E`, the format `E` is now similar to `EE` and `EEE`.
  - the timezone `z` will now fallback to `O` and output `GMT+1` instead of the complete zone name (e.g. `Pacific Standard Time`), this is because the quantity of data required to have all the zone names in all of the existing locales is too big.
  - the timezone `Z` will now output the ISO8601 basic format, e.g. `+0100`, you should now use `ZZZZ` to get `GMT+01:00`.

  | Field type | Format        | Example value         | v4 | v5            |
  |------------|---------------|-----------------------|----|---------------|
  | Eras       | Narrow        | A for AD              | G  | GGGGG         |
  | Months     | Narrow        | S for September       | L  | MMMMM         |
  | Week day   | Narrow        | M for Monday          | E  | EEEEE         |
  | Timezone   | Long location | Pacific Standard Time | z  | Not available |
  | Timezone   | Long GMT      | GMT+01:00             | Z  | ZZZZ          |

* Features
  - new predefined formats `long`, `full`, `longTime`, `fullTime`.
  - the format `yyy` is now supported, e.g. the year `52` will be `052` and the year `2017` will be `2017`.
  - standalone months are now supported with the formats `L` to `LLLLL`.
  - week of the year is now supported with the formats `w` and `ww`, e.g. weeks `5` and `05`.
  - week of the month is now supported with the format `W`, e.g. week `3`.
  - fractional seconds are now supported with the format `S` to `SSS`.
  - day periods for AM/PM now supports additional formats `aa`, `aaa`, `aaaa` and `aaaaa`. The formats `a` to `aaa` are similar, while `aaaa` is the wide version if available (e.g. `ante meridiem` for `am`), or equivalent to `a` otherwise, and `aaaaa` is the narrow version (e.g. `a` for `am`).
  - extra day periods are now supported with the formats `b` to `bbbbb` (and `B` to `BBBBB` for the standalone equivalents), e.g. `morning`, `noon`, `afternoon`, ....
  - the short non-localized timezones are now available with the format `O` to `OOOO`. The formats `O` to `OOO` will output `GMT+1` while the format `OOOO` will be `GMT+01:00`.
  - the ISO8601 basic time zones are now available with the formats `Z` to `ZZZZZ`. The formats `Z` to `ZZZ` will output `+0100`, while the format `ZZZZ` will be `GMT+01:00` and `ZZZZZ` will be `+01:00`.

* Bug fixes
  - the date pipe will now work exactly the same across all browsers, which will fix a lot of bugs for safari and IE.
  - eras can now be used on their own without the date, e.g. the format `GG` will be `AD` instead of `8 15, 2017 AD`.

3. Currency pipe
* Breaking change:
  - the default value for `symbolDisplay` is now `symbol` instead of `code`. This means that by default you will see `$4.99` for `en-US` instead of `USD4.99` previously.

* Deprecation:
  - the second parameter of the currency pipe (`symbolDisplay`) is no longer a boolean, it now takes the values `code`, `symbol` or `symbol-narrow`. A boolean value is still valid for now, but it is deprecated and it will print a warning message in the console.

* Features:
  - you can now choose between `code`, `symbol` or `symbol-narrow` which gives you access to more options for some currencies (e.g. the canadian dollar with the code `CAD` has the symbol `CA$` and the symbol-narrow `$`).

4. Percent pipe
* Breaking change
  - if you don't specify the number of digits to round to, the local format will be used (and it usually rounds numbers to 0 digits, instead of not rounding previously), e.g. `{{ 3.141592 | percent }}` will output `314%` for the locale `en-US` instead of `314.1592%` previously.

Fixes #10809, #9524, #7008, #9324, #7590, #6724, #3429, #17576, #17478, #17319, #17200, #16838, #16624, #16625, #16591, #14131, #12632, #11376, #11187

PR Close #18284
2017-08-22 15:43:58 -05:00
Zhicheng Wang
5976e2a35f fix: translation mistake 2017-08-22 21:12:48 +08:00
Olivier Combe
ec56760c9b refactor(common): remove deprecated NgFor (#18758)
BREAKING CHANGE: `NgFor` has been removed as it was deprecated since v4. Use `NgForOf` instead. This does not impact the use of`*ngFor` in your templates.

PR Close #18758
2017-08-21 18:11:01 -05:00
Zhicheng Wang
b88204dffb fix: typo #243 #244 #246 2017-08-21 21:38:37 +08:00
lin
28eb918651 spelling mistake
树组=>数组
2017-08-21 21:33:16 +08:00
lin
c628ef0240 translate mistake
english part: The `:id` in the second route
current translation: 第一个路由中的:id
2017-08-21 21:32:48 +08:00
Zhicheng Wang
de34171fa2 Merge remote-tracking branch 'origin/master' into aio
# Conflicts:
#	aio/content/guide/aot-compiler.md
#	aio/content/guide/change-log.md
#	aio/content/guide/ts-to-js.md
#	aio/content/marketing/docs.md
#	aio/content/navigation.json
#	aio/src/app/documents/document.service.ts
2017-08-20 19:39:38 +08:00
Zhicheng Wang
ed507026cb fix: typo 2017-08-20 15:05:23 +08:00
Tea
7f4c964eef docs(aio): typo in template-syntax guide (#18765)
PR Close #18765
2017-08-18 17:13:15 -05:00
Georgios Kalpakas
17b71ae382 docs(aio): move code snippet to appropriate location (#18650)
PR Close #18650
2017-08-18 13:23:09 -05:00
cexbrayat
5f5a8e1da6 docs(aio): typo in metadata guide (#18730)
PR Close #18730
2017-08-17 18:01:20 -05:00
Zhicheng Wang
70e9685c4f fix: minor improvement 2017-08-16 09:11:16 +08:00
Zhicheng Wang
c1481a1c23 fix: minor improvement 2017-08-16 09:10:28 +08:00
ksvitkovsky
c65f18a2fa docs(forms): fix reactive-forms guide typo
closes #17943
2017-08-15 16:42:58 -07:00
Ward Bell
697c6ed0fe docs: remove TypeScript to JavaScript guide & sample 2017-08-15 16:31:31 -07:00
Kapunahele Wong
9320f34f19 docs(aio): add Metadata guide based on Chuck’s docs
Chuck’s gist
https://gist.github.com/chuckjaz/65dcc2fd5f4f5463e492ed0cb93bca60#file-Angular%20Metadata-md
Also chuck’s doc on metadata-related errors (link needed)
2017-08-15 12:14:57 -07:00
George Kalpakas
fd6ae571b8 fix(aio): add missing code snippet (#18547)
The snippet got lost some time during the migration from the old version (it is
[present in v2][1]).

[1]: https://v2.angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#running-the-application

Fixes #18544
2017-08-09 14:20:25 -07:00
Zhicheng Wang
ace9bf9ace fix: minor issue 2017-08-08 13:32:04 +08:00
Zhicheng Wang
aeaa3bdefa fix: translate more 2017-08-08 13:18:51 +08:00
Zhicheng Wang
a6df16f891 Merge branch 'master' into aio
# Conflicts:
#	aio/content/guide/form-validation.md
#	aio/content/guide/i18n.md
#	aio/content/guide/reactive-forms.md
#	aio/content/marketing/index.html
#	aio/content/navigation.json
#	aio/src/environments/environment.stable.ts
2017-08-08 13:10:17 +08:00
Zhicheng Wang
5401322110 fix: 修正在线例子的链接 2017-08-07 08:10:17 +08:00
Zhicheng Wang
e29188ad54 fix: 快速起步改为快速上手 2017-08-07 07:49:44 +08:00
Zhicheng Wang
f2d870e0b8 fix: translate the rest of structural directives 2017-08-06 14:08:44 +08:00
Zhicheng Wang
74f98b871c fix: minor improvement 2017-08-06 13:45:13 +08:00
Zhicheng Wang
de6cfeeee3 clean: remove useless codes 2017-08-06 13:42:51 +08:00
Zhicheng Wang
0eaf9156de fix: use new translation logic 2017-08-06 13:37:25 +08:00
Zhicheng Wang
4c2b0b51b7 fix: some untranslated english 2017-08-06 13:23:56 +08:00
Zhicheng Wang
3a584ba96c fix: some untranslated english 2017-08-06 13:21:34 +08:00
Zhicheng Wang
477be082fb fix: minor improvement 2017-08-06 08:06:53 +08:00
Zhicheng Wang
019cd2e09c fix: minor improvement 2017-08-06 08:05:08 +08:00
Zhicheng Wang
446b0be846 fix: minor improvement 2017-08-05 23:51:25 +08:00
Zhicheng Wang
e7692d9e6f fix: translated language service 2017-08-05 23:49:55 +08:00
Zhicheng Wang
8d21900eb9 fix: minor improvement 2017-08-05 22:56:57 +08:00
Zhicheng Wang
2f17cb46c5 fix: missing break lines 2017-08-05 22:47:21 +08:00
Zhicheng Wang
2e97123611 fix: minor issue 2017-08-05 22:41:26 +08:00
Zhicheng Wang
36206ac2cf fix: minor issue 2017-08-05 22:40:17 +08:00
Zhicheng Wang
1de1da605b fix: translated http-client 2017-08-05 22:32:31 +08:00
Zhicheng Wang
5834211133 fix: a minor mistake (#235) 2017-08-05 18:02:40 +08:00
Zhicheng Wang
a2cb8b052b fix: translated the rest of visual studio 2015 2017-08-05 13:41:29 +08:00
Zhicheng Wang
ab47b12f52 fix: translated the rest of i18n 2017-08-05 13:23:14 +08:00
Zhicheng Wang
160306833c fix: translated the rest of template-syntax 2017-08-05 12:47:14 +08:00
Zhicheng Wang
b0d988c38f fix: translated the rest of router and structural-directives 2017-08-05 09:41:33 +08:00
Zhicheng Wang
0ddf72745e fix: translate all pure english titles 2017-08-04 14:06:15 +08:00
Zhicheng Wang
41c73556e6 fix: minor improvement 2017-08-04 13:27:54 +08:00
Zhicheng Wang
bb2082d016 fix: add line break before all figure 2017-08-04 09:27:48 +08:00
Zhicheng Wang
cfcd532b2f fix: a back to top link 2017-08-04 09:10:22 +08:00
Zhicheng Wang
96f0fcaf49 fix: missed quick start in navigation 2017-08-04 09:09:01 +08:00
Zhicheng Wang
cc33798597 fix: same examples 2017-08-04 08:58:13 +08:00
Zhicheng Wang
19088b76f8 fix: translate more 2017-08-04 08:47:51 +08:00
Zhicheng Wang
75ac1cd5ce fix: add line break before <code-example... 2017-08-04 07:39:15 +08:00