Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n - support global locale data #33523

Closed

Commits on Nov 4, 2019

  1. Copy the full SHA
    f00d632 View commit details
    Browse the repository at this point in the history
  2. build: support generating global locale files from CLDR data

    In order to support adding locales during compile-time
    inlining of translations (i.e. after the TS build has completed),
    we need to be able to attach the locale to the global scope.
    
    This commit modifies CLDR extraction to emit additional "global"
    locale files that appear in the `@angular/common/locales/global` folder.
    
    These files are of the form:
    
    ```
    (function() {
      const root = typeof globalThis !== 'undefined' && globalThis ||
          typeof global !== 'undefined' && global || typeof window !== 'undefined' && window;
      root.ng = root.ng || {};
      root.ng.common = root.ng.common || {};
      root.ng.common.locale = root.ng.common.locale || {};
      const u = undefined;
      function plural(n) {
        if (n === 1) return 1;
        return 5;
      }
      root.ng.common.locale['xx-yy'] = [...];
    })();
    ```
    
    The IIFE will ensure that `ng.common.locale` exists and attach the
    given locale (and its "extras") to it using it "normalized" locale
    name.
    
    * "extras": in the UMD module locale files the "extra" locale data,
    currently the day period rules, and extended day period data, are
    stored in separate files under the "common/locales/extra" folder.
    
    * "normalized": Angular references locales using a normalized form,
    which is lower case with `_` replaced by `-`. For example:
    `en_UK` => `en-uk`.
    petebacondarwin committed Nov 4, 2019
    Copy the full SHA
    e9b7e2a View commit details
    Browse the repository at this point in the history
  3. build: generate global locale files

    This commit contains the global locale files generated by the change to
    the CLDR `extract.js` tool, from the previous commit.
    petebacondarwin committed Nov 4, 2019
    Copy the full SHA
    bbd492f View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    29957bd View commit details
    Browse the repository at this point in the history
  5. refactor(common): move the low level locale registering to core

    To limit the exposure of the private `LOCALE_DATA` from outside
    `@angular/core` this commit exposes private functions in the core
    to hide the internal structures better.
    
    * The `registerLocaleData()` implementation has moved from
    `@angular/common` to `@angular/core`. A stub that delegates to
    core has been left in common for backward compatibility.
    * A new `ɵunregisterLocaleData()` function has been provided,
    which is particularly useful in tests to clear out registered locales
    to prevent subsequent tests from being affected.
    * A private export of `ɵregisterLocaleData()` has been removed
    from `@angular/common`. This was not being used and is accessible
    via `@angular/core` anyway.
    petebacondarwin committed Nov 4, 2019
    Copy the full SHA
    88d71da View commit details
    Browse the repository at this point in the history
  6. feat(common): support loading locales from a global

    To support compile time localization, we need to be
    able to provide the locales via a well known global property.
    
    This commit changes `getLocaleData()` so that it will attempt
    to read the local from the global `ng.common.locales` if the
    locale has not already been registered via `registerLocaleData()`.
    petebacondarwin committed Nov 4, 2019
    Copy the full SHA
    2bcf194 View commit details
    Browse the repository at this point in the history